Hello Max,
can you please show your code or add a link to your code?
Which version you are using?
Greetings,
Sven
Thread Starter
max_Q
(@max_q)
Version 1.0.0-beta.3
I straight copied and pasted the “Example” code from http://torro-forms.com/api/extending/elements/ into the root of a plugin. Then I wrapped it in the “How to add your code” function (function your_torro_functionality(){}).
As I said, it adds the new element just fine when I change it to call the register() method from the Torro_Element_Types_Manager class (torro()->element_types()->register( ‘My_Element’ );) rather than the Torro_Elements_Manager class (torro()->elements()->register( ‘My_Element’ );) as in the example code.
You are totally right! I will check this and give you feedback!
Thread Starter
max_Q
(@max_q)
The example code works fine now.
I might suggest adding a “if( function_exists( torro_load ) )” to the “How to add your code” example. If Torro Forms gets deactivated while your custom elements plugin is still active you get a fatal error. Ask me how I know.
Cheers
Thread Starter
max_Q
(@max_q)
Thread Starter
max_Q
(@max_q)
Found another issue with the example code: on viewing the form on the front end, I got three errors –
Warning: Missing argument 1 for Torro_Element_Type::get_input_id()
Warning: Missing argument 1 for Torro_Element_Type::get_input_id()
Warning: Missing argument 1 for Torro_Element_Type::get_input_name()
The errors correspond to the lines in the example code inside the get_input_html() function where $this->get_input_id() is called twice and $this->get_input_name() is called once.
I noticed that in your core elements, you are passing an $element argument to each of those functions, as in $this->get_input_id( $element ), but not in the example code. You’re passing in that $element argument when you call the get_input_html( $element ) function.
Thank you! I will take a look! π
I am very sorry, but as I find out, we have made breaking changes at this place. We have changed the way a bit, elements are beeing created because we invented the elements Templates that everybody can change the form elements layout for their purposes.
We did not have finished the docs yet, but we are on it at the moment. I will let you know if the docs also have changed or if you want to know more before, take a look at our elements code in the Torro Forms beta 4.
Hello Max,
we have rewritten the docs for the elements. Here You will find how to add elements now:
http://torro-forms.com/api/extending/elements/
I’m sorry for breaking changes. But we hope you like the changes. π
Greetings,
Sven
Thread Starter
max_Q
(@max_q)
Thanks. Look forward to experimenting.