func option of dependent field

edited July 2016 in Share
Hi could it be possible to give me an example of the func option on a dependent field as im struggling to see how this works or what is sent to it. What im trying to do is get the dependent field to return a template or block containing a form which contains fields from another table these values will then be saved as a serialized field. i will be building up the template based on the id of the dependent field id.

Comments

  • edited 6:18AM
    The "func" parameter is just a callable function and uses the PHP call_user_func. So you need to create a function or a class with method (which would be an array of array($myclass, 'method')) to do the rendering of your field. The function gets the array of parameters you passed to the dependent field.
    // A function perhaps in you fuel/application/helpers/my_helper.php function my_func($params) { // your custom field code goes here } // Then in your form code $fields['myfield'] = array('type' => 'dependent', 'func' => 'my_func');

    However, what it sounds like you are wanting to do is similar to using a "block" field that uses block layouts that perhaps contains a "template" field type:
    http://docs.getfuelcms.com/general/forms#block
    http://docs.getfuelcms.com/general/layouts#layouts_block_layouts
    http://docs.getfuelcms.com/general/forms#template
  • edited 6:18AM
    Thanks for the response I used a bit of js in the end to ajax form fields into a tab on the form does the job nicely
Sign In or Register to comment.