• Resolved max_Q

    (@max_q)


    Experimenting with your example code for adding an element, I get “Fatal error: Call to undefined method Torro_Elements_Manager::register()” called by torro()->elements()->register( ‘My_Element’ );

    It doesn’t seem that the Torro_Elements_Manager class has or inherits a register() method.

    I noticed the base elements use torro()->element_types()->register(), so I replaced elements with element_types and it seemed to work.

    Maybe something’s changed since you did the documentation, or am I missing something?

    https://www.ads-software.com/plugins/torro-forms/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Sven Wagener

    (@mahype)

    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 https://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.

    Plugin Author Sven Wagener

    (@mahype)

    You are totally right! I will check this and give you feedback!

    Plugin Author Sven Wagener

    (@mahype)

    Hey Max,

    Can you please download the latest Version of Torro Forms and checkout our latest API changes here:

    https://torro-forms.com/api/extending/elements/

    Torro Forms develop version:

    https://github.com/awsmug/torro-forms/tree/develop

    I’m sorry for that issue I have missed to test the examples. But now I did it. ??

    Greetings,

    Sven

    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)

    Looks like you might have to edit the “Register an element” section of https://torro-forms.com/api/using-torro/torro-elements/

    It’s calling that same method: torro()->elements()->register( ‘Element_Class_Name’ );

    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.

    Plugin Author Sven Wagener

    (@mahype)

    Thank you! I will take a look! ??

    Plugin Author Sven Wagener

    (@mahype)

    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.

    Plugin Author Sven Wagener

    (@mahype)

    Hello Max,

    we have rewritten the docs for the elements. Here You will find how to add elements now:

    https://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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Method not found’ is closed to new replies.