سؤال

I searched the internet for a while now, but can't find any hints on how to do this.

I wrote my own component in joomla 2.5 and it works fine so far. Part of the component is a form in the backend. The fields are a bit more complicated, but to keep it as simple as possible, it's basically like this:

    <input name="alpha" ....>
    <input name="beta" ....>
    <input name="gamma" ....>

To implement that with jform was no problem. But I need this part of the form various times repeated (like a table).

    <input name="alpha1" ....>
    <input name="beta1" ....>
    <input name="gamma1" ....>

    <input name="alpha2" ....>
    <input name="beta2" ....>
    <input name="gamma2" ....>

    <input name="alpha3" ....>
    <input name="beta3" ....>
    <input name="gamma3" ....>

    ...

I can't imagine, it would be smart to have like 100 sets of fields in the xml file, and then use only some of them. So my next approach was two create my own costum field, which extends a standard field and add another parameter (like an index) which would be used to alter the name tag of the input field. I guess that wouldn't work, since I don't call the getIndex() method of the field class but of the jform class (and there are only 3 parameters).

So I couldn't figure out how to do this with jforms. I now have kinda solution by just using php to get the html structure, but I would prefer to do it with jforms, so I could use the standard and custom from fields.

I appriciate any help on this and I'm still a newbie, so if this is the wrong approach, please let me know.

Thanks

هل كانت مفيدة؟

المحلول

Use alpha[] as the name. This way when the form is posted all repeat data is posted as an array

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top