I made a plugin to solve my problem of generating fields (or form attributes) retrieving data from other pages. It works fine and it is almost generic. But, there is a but. Here is how I call my plugin within the form:
The first argument passed to DynamicFormPlugin::field is the page path. The second argument is the property that I want to use to populate my fields.
The problem: I need to pass a method (or a path to the method, I couldn’t find out how that works with grav, yaml nor php) to DynamicFormPlugin::field, so it could use that function to map the property to the form attribute.
I thought about passing class::method as a third argument to DynamicFormPlugin::field. But I don’t know how to call the method later.
And I use call_user_func in DynamicFormPlugin::mapPropertyToFormAttribute to execute the function that does the mapping, passing the property to it:
/**
* Call the function that converts the property to a form attribute,
* passing the property as a parameter. The function needs to return the attribute info.
*/
return call_user_func($map_func_path, $selected_property);
@matepaiva, did you publish this anywhere? I could not see an applicable repository on your GitHub-profile. I’m particularly interested in whether data-fields@ worked for you, and would love to see any example of it in use.
Hey @matepaiva,
I think your plugin could be of great use for my volunteer team management intranet.
Could you somehow share it here or elsewhere ?
(take care and thank you for your contribution !)
Hello @medi and @OleVik! I didn’t think my plugin would be useful for others so I didn’t publish it yet. But I will do it this weekend and I come back here with the link. Thank you!