Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » generic views edit form

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1294 Views
  • wildflower1975
    Avatar
    Community Member
    59 Posts

    generic views edit form Link to this post

    Can I override a particular field in a scaffolded form and if so where?

    I have defined the field in the $db array to be of type Text but am using a DropdownField to populate it, so when I use the edit form a text box is being shown without the other options.

    I have other fields in my $db array using the Enum type and they are showing in the edit form with a DropdownField type, but using an Enum type for my Text field above would result in cryptic options being displayed (i.e the values of the Dropdownfield).

    I'm guessing I need to reuse my initial form on the 'Contoller extends Page_Controller' but in an edit mode with the fields pre-populated instead.

    Does anybody have a link or sample code for this?

    thanks

  • KINKCreative
    Avatar
    Community Member
    56 Posts

    Re: generic views edit form Link to this post

    Use scaffoldSearchFields() in your class... eg.

       public function scaffoldSearchFields()
       {
          $fields = parent::scaffoldSearchFields();

          //override fields
          $updatedField = new Textfield(...)

          $fields->replaceField('FieldName', $updatedField);
          return $fields;
        }

    1294 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.