?
avatar angelovianajr
angelovianajr
21 Nov 2017

When creating a custom form field, is possible extend from another filelds, ex.: JFormFieldList, JFormFieldText. And when extend of this filelds, is usual to override the getInput() or getOptions() methods.

Now, I'm extending JFormFieldList, and I want to keep the original getInput() but adding a custom attribute to each option of select.

I think that this to work, the ideal would be to add some property to the option, and on the HTML renderer options() function read this attr and add to the generated html

Below, how I want to override getOptions()

    protected function getOptions(){
        $options = parent::getOptions();
        foreach ($options as $option) {
            $option->attr="myattr='valueofmyattr'";
        }
        return $options;
    }
avatar angelovianajr angelovianajr - open - 21 Nov 2017
avatar joomla-cms-bot joomla-cms-bot - change - 21 Nov 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Nov 2017
avatar joomla-cms-bot joomla-cms-bot - change - 22 Nov 2017
Status Information Required New
avatar joomla-cms-bot joomla-cms-bot - edited - 22 Nov 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Nov 2017
Category com_fields
avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Nov 2017
Title
When creating custom form field that extends list field, is not possible to add custom attr to each option
[com_fields] When creating custom form field that extends list field, is not possible to add custom attr to each option
Status New Information Required
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Nov 2017

@laoneo any Clue?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18787.

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Nov 2017
Status New Information Required
avatar laoneo
laoneo - comment - 22 Nov 2017

Yes something like that can work. But I think it is better to ask in the forum.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Nov 2017

@angelovianajr as @laoneo suggested please ask help on the forums. (this repository concerns in first Place Joomla coding. For this Reason closing this Issue, thanks).

@laoneo thanks for Info.

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Nov 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-11-22 07:46:28
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 22 Nov 2017
Closed_Date 2017-11-22 07:46:28 2017-11-22 07:46:29
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 22 Nov 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 22 Nov 2017

Add a Comment

Login with GitHub to post a comment