Вопрос

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