madeyourday / contao-rocksolid-custom-elements

RockSolid Custom Elements Contao Extension
http://rocksolidthemes.com/de/contao/plugins/custom-content-elements
MIT License
48 stars 12 forks source link

Create standardField with different name #71

Closed christianromeni closed 8 years ago

christianromeni commented 8 years ago

It would be awesome if it could be possible to create a standardField with a different name. For example:

'headline' => array(
    'inputType'    => 'standardField',
    'standardType' => 'headline',
    'options'      => array('h1'),
),
'subheadline' => array(
    'inputType'    => 'standardField',
    'standardType' => 'headline',
    'options'      => array('h2', 'h3'),
),

What do you think?

ausi commented 8 years ago

That is not possible, because a standardField stores the data in the database column of the same name. So the two fields would overwrite each other.

But a headline field can be created easily without being a standardField:

'subheadline' => array(
    'label' => &$GLOBALS['TL_LANG']['tl_content']['headline'],
    'inputType' => 'inputUnit',
    'options' => array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'),
    'eval' => array('maxlength' => 200),
),
christianromeni commented 8 years ago

Yep.. I know that... And I took a simple field to demonstrate. But lets just think I want to add the imageSize that is used in any regular DCA... Then I would need to copy it for every image I want to size in rsce.

But If I just say: this field here in rsce: 'thumbnail_size' will inherit all the settings from the standard field "imageSize". Then I dont have to copy the whole dca part. I'll just let the field know what options it should have.

I think we missunderstood each other :-)

ausi commented 8 years ago

I think this should be possible with:

'subheadline' => $GLOBALS['TL_DCA']['tl_content']['fields']['headline'],
christianromeni commented 8 years ago

Ahh...... clever...... Yep.. That is a nice one 👍 I'll test it.

christianromeni commented 8 years ago

Sorry to open this up again, but is it also possible to manipulate the array ($GLOBALS['TL_DCA']['tl_content']['fields']['headline'])? In this example I would like to change the options so that h1 is not included..

ausi commented 8 years ago

Yes, since the config files are regular PHP files, you can do whatever you want in them.