Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Is it possible to add a placeholder to an editable region of type text or textarea?
Sure.
Assuming following are the two editable regions we are interested in -
Code: Select all
<cms:template>
    <cms:editable name='name' type='text' />
    <cms:editable name='address' type='textarea' />
</cms:template>

Use <cms:config_form_view> to custom render them adding the 'placeholder' parameters as follows -
Code: Select all
<cms:template>
    <cms:editable name='name' type='text' />
    <cms:editable name='address' type='textarea' />
   
    <cms:config_form_view>
        <cms:field 'name'>
            <cms:input name=k_field_input_name type='bound' trust_mode='1' placeholder='First name' />
        </cms:field>

        <cms:field 'address'>
            <cms:input name=k_field_input_name type='bound' trust_mode='1' placeholder='Full address' />
        </cms:field>
    </cms:config_form_view>
</cms:template>

Result:
Untitled-1.png
Untitled-1.png (3.57 KiB) Viewed 226 times

Hope it helps.
Yes! That works! Thank you so much. I didn't see anything about config_form_view in the documentation, must have missed it!
You are welcome :)

I didn't see anything about config_form_view in the documentation,

You can find all the details about <cms:config_form_view> and its counterpart <cms:config_list_view> here -
viewtopic.php?f=5&t=10241

Basically both allow easy customization of the form and list screens in the admin-panel.
have a question about repeatable. how to insert placeholder to repeatable field?

NOT WORKS WITH

Code: Select all
   <cms:repeatable name="list_repeatable" label="Manufacturers list" order='20'>
      <cms:editable type='image' name="logo"  />
      <cms:editable type='text' name="url" label='URL on page' />
   </cms:repeatable>


    <cms:config_form_view>
        <cms:field 'url'>
            <cms:input name=k_field_input_name type='bound' trust_mode='1' placeholder='http://' />
        </cms:field>
   </cms:config_form_view>
I would also be interested in knowing how to make it work with Repeatable Regions.

Thanks!
@andrejprus, @larin555,
When a field is defined within a repeatable_region, the 'field' as seen by <cms:config_form_view> is actually the repeatable-region (and not its children). That would explain why the method does not work with child regions.

Anyway, we can use an alternate (albeit slightly more involved) method to set custom attributes on 'text' and 'textarea' regions.
This method is a variation of the method described here - viewtopic.php?f=2&t=10438&p=25693#p25696

So, if you have not already done this, begin with activating the 'sample' admin theme by uncommenting (i.e. removing the leading double-slashes '//') the line highlighted below in couch/config.php -
// 26.
// If the admin-panel uses a custom theme, set the following to the folder-name of the theme.
// Theme folder is expected to be within the 'couch/theme' folder. No leading or trailing slashes please.
//define( 'K_ADMIN_THEME', 'sample' );

Now place the attached three files within the 'couch/theme/sample' folder.

IMP: If you have already made any custom changes to the existing 'kfunctions.php' within the 'couch/theme/sample' folder mentioned above, please manually add to your existing file the new changes from the attached 'kfunctions.php' file.

And now, suppose the original definition of a text/textarea editable region is as follows -
Code: Select all
<cms:editable type='text' name="url" label='URL on page' />

- you may add any custom attribute to it by using the 'custom_styles' attribute as follows -
Code: Select all
<cms:editable type='text' name="url" label='URL on page' custom_styles="placeholder='https://'"  />

Any text placed between the two double-quotes of 'custom_styles' attribute will be outputted verbatim in the generated input's HTML.

Please note that the technique above will work for normal text/textarea editable regions as well as those defined as repeatable.

Hope this helps.

Attachments

Awesome! Thanks KK
hi @KK, what about documentation update with all new additionals params and features??
9 posts Page 1 of 1

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests

cron