简体   繁体   中英

sonata color the fields

I am trying to understand how Sonata works and I have a question. I saw something nice about their demo and I can not find in their documentation like to do. Maybe you can help me.

In the fields they arrive to color values according to criteria surely of the value of the latter I would like to know how to do. I put a small screen that I took on their site that help you maybe to understand my request. 多彩的田野

I have a small form which I also put the code and I would like to be able to color in green the "client" in red "ex-client" and in blue "prospect" how am I supposed to do?

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->tab('General Information',array('class'=>'col-md-9'))
        ->with('', array('class'=>'col-md-9'))
        ->add('firstName', 'text')
        ->add('surname', 'text')
        ->add('address', 'text',array('required'=> false))
        ->add('email', 'email', array(
            'required' => false))
        ->add('Phone', 'text', array(
            'required' => false))
        ->add('birthdate', 'birthday', array('label' => 'Date of Birth','required'=>false))
        ->end()
        ->with('Others Informations',array('class'=>'col-md-3'))
        ->add('Status', 'choice', array(
            'choices' => array(
                'Client' => 'Client',
                'Ex-Client' => 'Ex-Client',
                'Prospect' => 'Prospect'),
        ))
        ->add('businessname', 'text', array('label' => 'Business Name','required'=>false))
        ->add('typeofbusiness', 'choice', array(
            'choices' => array(
                'Blank' => Null,
                'SE' => 'SE',
                'SA' => 'SA',
                'LLP' => 'LLP',
                'LTD' => 'LTD',
                'Payroll' => 'Payroll'),
            'label' => 'Type of buisness'
        ))
        ->end()
        ->end()
        ->tab('Comment',array('class'=>'col-md-12'))
        ->add('comments', 'textarea', array('required'=>false))
        ->end()
    ;
}



protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper
        ->add('surname')
        ->add('firstname')
        ->add('address')
        ->add('email')
        ->add('phone')
        ->add('birthdate', null, array(
            'label' => 'Date of birth (mm/dd/yyyy)'), 'sonata_type_datetime_picker', array(
            'format'                => 'MM/dd/yyyy',
            'dp_side_by_side'       => true,
            'dp_use_current'        => false,
            'dp_use_seconds'        => false,
        ))
        ->add('status')
        ->add('businessname')
        ->add('typeofbusiness')
        ->add('comments')
    ;

}

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->addIdentifier('surname')
        ->add('firstname')
        ->add('address')
        ->add('email')
        ->add('phone')
        ->add('birthdate')
        ->add('Status')
        ->add('businessname')
        ->add('typeofbusiness')
        ->add('comments');
}

public function toString($object)
{
    return $object instanceof Client
        ? $object->getSurname()
        : 'Client'; // shown in the breadcrumb on the create view
}

}

Also in the installation and grip they make us create a BlogPost but nowhere I have defined anything and the boolean values are in red or green. I really do not understand how to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM