October: Support passing arrays to the SyntaxParser used by RainLab.Pages for field generation

Created on 16 Mar 2017  路  5Comments  路  Source: octobercms/october

Sup!

When I needed to add a color picker to static page, I discovered that that expects to receite an array... and attribute availableColors="" didn't work as expected...

My solution can be "noobby" but, why you don't add some code like that, to filter the string? :)

image

public function prepareVars()
    {
        $this->vars['name'] = $this->getFieldName();
        $this->vars['value'] = $value = $this->getLoadValue();

        if(!is_array($this->availableColors))
            $this->availableColors = preg_split('/[\ \,]/', $this->availableColors);

        $this->vars['availableColors'] = $this->availableColors;
        $this->vars['isCustomColor'] = !in_array($value, $this->availableColors);
    }

tryingtobeuseful

Low Archived Conceptual Enhancement

Most helpful comment

I believe this is already supported in the Dropdown and Radio buttons fields through the syntax parser. Support was added for it in https://github.com/octobercms/library/commit/4b27731a30f0abf1646472cf2a8f755a95281b0d, so I think it should be relatively easy to add support for it to the colorpicker widget as well.

When I have the time to review this in more detail I'll take a look at doing that for you.

All 5 comments

I believe this is already supported in the Dropdown and Radio buttons fields through the syntax parser. Support was added for it in https://github.com/octobercms/library/commit/4b27731a30f0abf1646472cf2a8f755a95281b0d, so I think it should be relatively easy to add support for it to the colorpicker widget as well.

When I have the time to review this in more detail I'll take a look at doing that for you.

availableColors="red|yellow|green"

Hi! I have the same problem
availableColors="red|yellow|green"
is not working :(

The support demand for October is increasing, while the available time the founders have to give remains the same. These issues will be handled in time, however there are ways you can help:

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see action on it, please respond and we will get the ball rolling.

Was this page helpful?
0 / 5 - 0 ratings