symfony - Display name instead of DB value in SonataAdmin List View -
I am having a problem when I try to list records from DB because I get the value stored in the row Is integer, but I want string instead of how am I handling the form? Like this:
Protected function configured form field (formmer $ form) {$ form - & gt; Add ('no_order', null, array ('label' = & gt; 'no command')) - & gt; Add ('company', 'unit', array ('class' = & gt; 'PL company company bundle' unit 'company', 'label' = & gt; 'client')) - & gt; Add ('business_case', zero, array ('label' = & gt; 'BC')) - & gt; Array ('empty_value' = & gt; "Seleccione una opción", "0" = & gt; "ninguno", "1" = & quot; ('charge_status', 'option', array ('option' => Gt; "Proceso de Fabricacion", "2" => "Pick Ann Destino", "3" => "A La espera de recojo por cliente", "4" => "Caraga en Transito" , "5" = & gt; "Caraga Aribada", "6" => "N Prosso de Eduana", "7" => "Antragrado Client" "8" => "En Bodga"), " Required "= & Gt; true, 'label' = & gt; 'Estado de la carga')) - & gt; Add ('eta', zero, array ('label' = & gt; 'ETA', 'widget' = & gt; 'single_text', 'required' => false, 'attr' = & gt; array 'Class' = & gt;' datepicker ') -' ETD ',' widget; ETD ', zero, array (' label '= & gt' ') & gt (add' '= & gt;' single_text '(' Class '= & Gt;' datepicker '))))) - & gt; Add ('transport_media', 'like', array ('option' => gt; 'required' = & gt; wrong, 'attr' => array ("empty_value" => "Seleccione una opción" , "0" = & gt; "EXW", "1" = & gt; "maritime", "2" => "Ario"), "required" = array ('empty_value' => array ( "Empty_man" = & gt; true, 'label' = & gt; via 'via de transport')) - & gt; add ('incontum', 'likes' "," 0 "= & gt;" Ningungo "," 1 "= & gt;" EWX "," 2 "=>" FOB "," 3 "=> CIF," 4 "=>" DDP ")," Required " = & Gt; true, 'label' = & gt; 'incotam')) - & gt; add ('comments', tap, sir Add (- '' Media '', 'sonata_type_collection', array ('required' = & gt; wrong) with '-' ('label' = & gt; 'comments')) -> ('Documentos') , Array ('Edit' = & gt; 'Inline', 'Inline' = & gt; 'Table', 'Sort' = & gt; 'Position')) -> End ();}
I defined charg_status
(in BC is in the equivalent view) as a choice, how can I show the string and not value in the list view? View attached image for problem view
An approach:
For example define a constant array in your unit:
"Ninguno", "1" => "Proceso de Fabricacion", "2" => "Pickup Ann Destino", "3 "= & Gt;" A La espera de recojo por cliente "," 4 "=>" carga en transito "," 5 "=>" carga arribada "," 6 "=>" N Processo De Eduana "," 7 "=>" Entergraduate A Client "," 8 "=>" En Bodga "); Public function getChargeStatusValue () {return self :: $ chargeStatus [$ this- & gt; Charg_status]; }}
Your Admin class expands
class YourAdmin administrator {.... use path / per / yours / organization; Protected Function Configurable ListsField (on Lispupper $ listmap) {$ listMapper - & gt; Add ('Chargestats value', 'string', array ('label' = & gt; 'charging status')); } Protected function configuredfieldfile (FormMaper $ form) {.... - & gt; Add ('charg_stats', 'likes', array ('option' => entity :: $ chargeStatusList)); ....}}
Comments
Post a Comment