1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to create an ACP option with unlimited entries

A stylish alternative to a simple textbox, stored in an array

  1. katsulynx

    katsulynx Well-Known Member

    katsulynx submitted a new resource:

    How to create an ACP option with unlimited entries - A stylish alternative to a simple textbox, stored in an array

    Read more about this resource...
     
    Scharesoft likes this.
  2. Hoffi

    Hoffi Well-Known Member

    A good solution, but can improve the template with the following:

    Simple Change OPTIONID to this:

    HTML:
    {$preparedOption.option_id}
    and instead of option[OPTIONID] better use

    HTML:
    {$fieldPrefix}[{$preparedOption.option_id}]
    Than add at the start
    HTML:
    <xen:controlunit label="{$preparedOption.title}">
    to use the original Name of the option.

    and at least bette delete this:
    HTML:
    <xen:if is="{$debugMode}">
    <a href="admin.php?options/edit-option/OPTIONID" class="optionEditLink inputSupplementary Tooltip" data-offsetx="5" data-offsety="-8" data-tipclass="flipped"><span class="editText">{xen:phrase text}</span></a>
    </xen:if>
    and replace it with this:

    HTML:
    {xen:raw $editLink}
    to let the controller display the Icon.

    Than, add this before closing the option.

    HTML:
    <p class="explain">{xen:raw $preparedOption.explain}</p>

    So, that we get thie Template at the end:

    HTML:
    <xen:controlunit label="{$preparedOption.title}">
        <ul class="FieldChoices">
            <xen:foreach loop="$preparedOption.option_value" key="$choice" value="$text">
                <xen:if is="{$text}">
                    <li>
                        <input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][]" value="{$text}" class="textCtrl" placeholder="{xen:phrase text}" size="25" />
                    </li>
                </xen:if>
               </xen:foreach>
                  <li>
                <input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][]" class="textCtrl" placeholder="{xen:phrase text}" size="25" />
               </li>
        </ul>
        <input type="button" value="{xen:phrase add_additional_choice}" class="button smallButton FieldAdder" data-source="ul.FieldChoices li" />
    
        <p class="explain">{xen:raw $preparedOption.explain}</p>
        {xen:raw $editLink}
    </xen:controlunit>
    
    Now, you can use this Template without changes for every returning Option, if you use this multiple times.
     
    Last edited: Aug 11, 2015
    Thomas.B and katsulynx like this.
  3. katsulynx

    katsulynx Well-Known Member

    I've worked your improvements into the guide after testing them. Thanks for sharing!
     
    Hoffi likes this.
  4. Cyb3r

    Cyb3r Well-Known Member

    Hello @katsulynx, I have been trying all day long to make more text fields without no luck.

    I'm trying to add 5 text fields (id, title, img, user, group), can you please give an example on how to make this work?

    Thanks in advance!
     
  5. mcatze

    mcatze Well-Known Member

    The default value should called a:0:{} .. ;)
     

Share This Page