Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Adding a field to the member complexTableField

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

Page: 1
Go to End
Author Topic: 2447 Views
  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Adding a field to the member complexTableField Link to this post

    Hello.

    I have managed to add an extra field to the member table through a dataobjectdecorator and I have also managed to get it into the member form that you get when you press edit on the complexTableField on the member table.

    However I can't find where the fields for the complexTableField are made/added. I would really like to get my dropdown list on the complexTableField since right now you first have to add a member and then edit which is very clumsy/unintuitive.

    I must also say that the documentation around modifying the member table is very lacking. A simple tutorial for decorating the member, adding a field to the member form and getting it on the complexTableField would go a long way to helping alot of people when it comes to member modification I think.

    Kindly, Marcus.

  • chrclaus
    Avatar
    Community Member
    29 Posts

    Re: Adding a field to the member complexTableField Link to this post

    Hello Smurkas,

    I think you managed your new attribute by adding it to the field_names and field_types array which are referenced in the ComplexTableField.

    ...
    $tableField = new ComplexTableField($this, 'Training', 'Training', Training::$field_names, $popupFieldsTraining);
    ...
    class Training ...
    static $field_types = array(
        'Title' => 'ReadonlyField',
        'Category' => 'DropdownField(\'CategoryID\', \'CategoryID\', DataObject::get(\'Category\')->toDropDownMap(\'ID\', \'Title\'))'
    );

    static $field_names = array(
        'Title' => 'Training description',
        'Category' => 'Category Description'
    );
    ...

    As you can see in the example, I added a DropDown-list in the ComplexTableField successfully.

    Best regards,
    chrclaus

  • CodeGuerrilla
    Avatar
    Community Member
    105 Posts

    Re: Adding a field to the member complexTableField Link to this post

    Anyone provide a better example of this am trying to add a field to the Members List got it working in the popup but for the life of me can't in the table list.

    Any help appreciated.

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Adding a field to the member complexTableField Link to this post

    I actually figured this out but forgot to report back.

    There is a function called addMembershipFields on the MemberTableField class. You can calll it like I do below.
    You are however severely limited in what kind of fields you can add since addMembershipFields only takes the fieldname and the title, not what kind of field you want. Because of this you'll always get text fields.

    You can put the code in the _config.php file.

    MemberTableField::addMembershipFields(
       array(
          "Address" => _t('RTVMemberTableField.ADDRESS', 'Adress'),
          "Boras" => _t('RTVMemberTableField.BORAS', 'BorÃ¥s'),
          "Uddevalla" => _t('RTVMemberTableField.UDDEVALLA', 'Uddevalla')
       )
    );

    Hope this helps!

  • CodeGuerrilla
    Avatar
    Community Member
    105 Posts

    Re: Adding a field to the member complexTableField Link to this post

    Hey thanks for the reply I did manage to find that but found the same thing I believe that function is also deprecated as of SS 2.3 my problem is I need a relational dropdown from another dataobject as mentioned the popup has this just not the tablelist see http://www.silverstripe.org/customising-the-cms/show/276815#post276815

    2447 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.