Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic form building / metaprogramming / PHP
    primarykey
    data
    text
    <p>I'm looking for design ideas about creating dynamic forms.</p> <p>What I currently have is a bunch of models with a few properties / variables for example:</p> <pre><code> class Group extends IDKModel { /** * @Form */ public $title; /** * @Form(validation="{my validation rules here}") */ public $permissions; } </code></pre> <p>In that example the Form PHPAnnotation defines it as a form element and the validation array will have built in validation rules in it. Now the problem I'm having is I have no idea how to implement conditionals. </p> <p>For example, how to show $permissions only if a user is an admin. How to show $title if time of day is past 12:00 GMT. Basically any kind of conditional. </p> <p>Taken from #php at irc.quakenet.org:</p> <pre><code>[10:50] &lt;ramirez&gt; i would not try to stick all of the meta-info under one attribute [10:50] &lt;ramirez&gt; it'd be much cleaner to do something like [10:50] &lt;ramirez&gt; @FormElement [10:51] &lt;ramirez&gt; @Validator(params) [10:51] &lt;ramirez&gt; etc [10:52] &lt;ramirez&gt; anyways, I would probably do something like.. @Filter(name="Group",value="admin,editor") [10:53] &lt;ramirez&gt; then for each filter you want to implement, you'll create a class like "Model_Filter_Group", which would be used for eg. the above filter [10:53] &lt;ramirez&gt; that class in this case would simply explode the groups by comma and see if user is in any of those groups [10:54] &lt;ramirez&gt; you can use that for any kind of filtering, eg: @Filter(name="PastTime", value="12:00") </code></pre> <p>Anyone have a simpler idea?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload