public function addFields(array $fieldData)
    {
        foreach ($fieldData as $k => $data) {
            $assoc = !is_numeric($k);
            $name = $assoc ? $k : $data;
            $field = ArrayData::create(
                [
                    'Name' => $name,
                    'Description' => $assoc ? $data : null,
                ]
            );
            $this->removeField($name);
            $this->fields->add($field);
        }

        return $this;
    }
public function addFields(array $fieldData)
    {
        foreach ($fieldData as $k => $data) {
            $assoc = !is_numeric($k);
            $name = $assoc ? $k : $data;
            $field = ArrayData::create(
                [
                    'Name' => $name,
                    'Description' => $assoc ? $data : null,
                ]
            );
            $this->removeField($name);
            $this->fields->add($field);
        }

        return $this;
    }
public function addFields ( array $ fieldData ) { foreach ( $ fieldData as $ k => $ data ) { $ assoc = ! is_numeric ( $ k ) ; $ name = $ assoc ? $ k : $ data ; $ field = ArrayData :: create ( [ 'Name' => $ name , 'Description' => $ assoc ? $ data : null , ] ) ; $ this -> removeField ( $ name ) ; $ this -> fields -> add ( $ field ) ; } return $ this ; }
Adds visible fields, and optional descriptions.

Ex:
[
'MyField' => 'Some description',
'MyOtherField' // No description
]

@param  array $fieldData
@return $this
Adds visible fields and optional descriptions .