문제

Perhaps someone can help me. I've just installed the Grid Field Extensions Module for Silverstripe (https://github.com/ajshort/silverstripe-gridfieldextensions) because I need inline editing/adding. It works, but simple TextFields are shown as textareas and not as a simple textfield.

Can someone tell me how to change that?

도움이 되었습니까?

해결책

The module attempts to automatically work out what field would be best for your variable. It will create a DropdownField for an Enum variable, TextareaField for a Text varialbe and so on.

If you don't want to manually set the field types for each variable that you want to be editable inline you need to change your variables a little.

TextareaField is the field set for Text variables.

TextField is the field set for Varchar variables.

For any variables that you want to be a TextField instead of a TextareaField change it's type from Text to Varchar(255) (or however large a character limit you need).

Otherwise you can manually set the fields using setDisplayFields as described in the documentation.

$grid->getConfig()->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array(
    'FirstField'  => function($record, $column, $grid) {
        return new TextField($column);
    }, 
    'SecondField'  => function($record, $column, $grid) {
        return new TextField($column);
    }, 
    // ... etc for each field you want to be editable
));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top