Gravity Forms Custom Select On List : Show label - gravity-forms-plugin

:)
I am using the Gravity Forms List field and have created a select field on one of the columns. I am also using gravity perks copy cat plugin so that the column field then copies the selected value to the second column.
Column 1 (Product Name) should have the input label,
Column 2 (Product ID) should have the value.
Only issue is that column 1 defaults back to the value when I am trying to pass the data to other forms.
This is my code. Is there a line I can add to ensure the input label is used in the select box?
Or is there another way to handle this?
add_filter( 'gform_column_input_104_7_1', 'Individual', 10, 5 );
function individual( $input_info, $field, $column, $value, $form_id ) {
return array(
'type' => 'select',
'choices' => array(
array( 'value' => '2837', 'text' => 'A0256-0 Mediana A10 AED Pads (Adult)'),
array( 'value' => '526', 'text' => 'AA01 Antiseptic Cream Sachet 1g'),
array( 'value' => '522', 'text' => 'AAB100 Amputated Parts Bag'),
array( 'value' => '528', 'text' => 'AAS50 Antiseptic Spray 50ml'),
array( 'value' => '536', 'text' => 'AB3 Burn Gel 3.5g Sachet'),
array( 'value' => '1057', 'text' => 'ABC10 Calico Triangular Bandage 110cm x 110cm'),
array( 'value' => '1453', 'text' => 'ABC10SU Calico Triangular Bandage 110cm x 110cm Single Unit'),
array( 'value' => '1451', 'text' => 'ABCH100 Cohesive Bandage Blue 10cm x 4.5m (Box 12)'),
array( 'value' => '1047', 'text' => 'ABCH100SU Cohesive Bandage Blue 10cm x 4.5m'),
array( 'value' => '1472', 'text' => 'ABCH25 Cohesive Bandage Blue 2.5cm x 4.5m Box 12'),
array( 'value' => '1043', 'text' => 'ABCH25SU Cohesive Bandage Blue 2.5cm x 4.5m'),
array( 'value' => '1452', 'text' => 'ABCH50 Cohesive Bandage Blue 5cm x 4.5m (Box 12)'),
array( 'value' => '1044', 'text' => 'ABCH50SU Cohesive Bandage Blue 5cm x 4.5m'),
array( 'value' => '1474', 'text' => 'ABCH75 Cohesive Bandage Blue 7.5cm x 4.5m Box 12'),
array( 'value' => '1045', 'text' => 'ABCH75SU Cohesive Bandage Blue 7.5cm x 4.5m'),
array( 'value' => '538', 'text' => 'ABD10 Burn Gel Dressing 10cm x 10cm'),
array( 'value' => '1471', 'text' => 'ABN10 Non-Woven Triangular Bandage 110cm x 110cm'),
array( 'value' => '680', 'text' => 'ABN10SU Non-Woven Triangular Bandage 110cm x 110cm'),
array( 'value' => '542', 'text' => 'ABS1010SU Burn Sheet 10cm x 10cm'),
array( 'value' => '2983', 'text' => 'ABS2020SU AEROBURN™ PE Burn Sheet 20cm x 20cm'),
array( 'value' => '2984', 'text' => 'ABS6090SU AEROBURN™ PE Burn Sheet 60cm x 90cm'),
array( 'value' => '563', 'text' => 'ACA150 Cotton Tip Single End Applicator (100)'),
array( 'value' => '545', 'text' => 'ACD1010SSU Combine Dressing 10cm x 10cm'),
array( 'value' => '547', 'text' => 'ACD1020SSU Combine Dressing 10cm x 20cm'),
array( 'value' => '549', 'text' => 'ACD2020SSU Combine Dressing 20cm x 20cm'),
array( 'value' => '1843', 'text' => 'ACE100SU Elastic Cotton Crepe Bandage 10 cm X 4m'),
array( 'value' => '1042', 'text' => 'ACE50SU Elastic Cotton Crepe Bandage 5cm x 4m'),
array( 'value' => '1454', 'text' => 'ACM100SU Medium Cotton Crepe Bandage 10cm x 4M'),
array( 'value' => '1461', 'text' => 'ACM150SU Medium Cotton Crepe Bandage 15cm x 4m'),
array( 'value' => '1466', 'text' => 'ACM25SU Medium Cotton Crepe Bandage 2.5cm x 4m'),
array( 'value' => '575', 'text' => 'ACM50SU Medium Cotton Crepe Bandage 5cm x 4m'),
array( 'value' => '577', 'text' => 'ACM75SU Medium Cotton Crepe Bandage 7.5cm x 4m'),
array( 'value' => '1054', 'text' => 'AD1000 Detectable Bandage Extra Wide'),
array( 'value' => '1055', 'text' => 'AD1001 Detectable Bandage Wide Patch'),
array( 'value' => '1475', 'text' => 'AD1007B AEROPLAST PREMIUM DETECTABLE BANDAGES Dressing Strip'),
array( 'value' => '866', 'text' => 'AEDA15 Mediana A15 Defibrillator'),
array( 'value' => '870', 'text' => 'AEDC AED Cabinet'),
array( 'value' => '585', 'text' => 'AEP1SSU Eye Pad Sterile'),
array( 'value' => '1476', 'text' => 'AF100SU Conforming Bandage 10cm x 4M'),
array( 'value' => '551', 'text' => 'AF25SU Conforming Gauze Bandage 2.5cm x 4m'),
array( 'value' => '553', 'text' => 'AF50SU Conforming Gauze Bandage 5cm x 4m'),
array( 'value' => '557', 'text' => 'AF75SU Conforming Gauze Bandage 7.5cm x 4m'),
array( 'value' => '682', 'text' => 'AF9 Tweezers Stainless Steel 7.5cm'),
array( 'value' => '898', 'text' => 'AFAK2S Voyager Versatile First Aid Kit'),
array( 'value' => '886', 'text' => 'AFAK3S Defender Versatile First Aid Kit'),
array( 'value' => '890', 'text' => 'AFAK4S Responder Versatile First Aid Kit'),
array( 'value' => '2826', 'text' => 'AFAK4T Aero Responder Series 4 Tackle Box Kit'),
array( 'value' => '894', 'text' => 'AFAK5S Operator Versatile First Aid Kit'),
array( 'value' => '880', 'text' => 'AFAK6S Commander Versatile First Aid Kit'),
array( 'value' => '875', 'text' => 'AFAKLSB-1 Comprehensive Snake Bite & Spider Bite First Aid Kit'),
array( 'value' => '821', 'text' => 'AFAKRW Regulator Remote Work Kit'),
array( 'value' => '2546', 'text' => 'AFAKSB Snake Bite Kit'),
array( 'value' => '2555', 'text' => 'AFAKSB-2 Snake Bite Kit X 2'),
array( 'value' => '1056', 'text' => 'AFB13 Forceps Blunt Stainless Steel'),
array( 'value' => '1886', 'text' => 'AFH100SU Heavyweight Conforming Bandage 10cm x 4 mtr'),
array( 'value' => '1477', 'text' => 'AFH50SU Heavy Weight Conforming Bandage 5cm x 4M'),
array( 'value' => '1041', 'text' => 'AFH75SU Heavy Weight Conforming Bandage 7.5cm x 4m'),
array( 'value' => '1478', 'text' => 'AFHSB100 Snake Bite Bandage w/indicator 10cm x 10.5M Pack 12'),
array( 'value' => '1479', 'text' => 'AFHSB100SU Snake Bite Bandage w/indicator 10cm x 10.5M'),
array( 'value' => '1480', 'text' => 'AFID6SSU Aerofix Island Dressing 6cm x 8cm'),
array( 'value' => '1481', 'text' => 'AFID8SSU Aerofix Island Dressing 9 x 10cm'),
array( 'value' => '676', 'text' => 'AFP11 Forceps - Disposable'),
array( 'value' => '595', 'text' => 'AFP350 Fabric Knuckle Dressings 40 Pkt'),
array( 'value' => '599', 'text' => 'AFP501 Fabric Plasters 100 Pkt'),
array( 'value' => '1048', 'text' => 'AFP50125 Fabric Dressing Strips (25)'),
array( 'value' => '597', 'text' => 'AFP5015 Fabric Plasters 50 Pkt'),
array( 'value' => '1049', 'text' => 'AFP506 Fabric Large Patch (25)'),
array( 'value' => '1482', 'text' => 'AFP601 AEROPLAST PREMIUM FABRIC BANDAGES X-Wide Strip Box 100'),
array( 'value' => '1483', 'text' => 'AFP6015 AEROPLAST PREMIUM FABRIC BANDAGES X-Wide Strip Box 50'),
array( 'value' => '591', 'text' => 'AFP701 Fabric Dressing Strip 7.5cm x 1m'),
array( 'value' => '1874', 'text' => 'AFPW010SU Waterproof Island Dressing 10 x 12cm'),
array( 'value' => '1876', 'text' => 'AFPW015SU Waterproof Island Dressing 15 x 20 cm'),
array( 'value' => '662', 'text' => 'AFS001 Face Shield Disposable'),
array( 'value' => '1484', 'text' => 'AFSB10 Short Snake Bite Bandage w/indicator 10cm x 4.5M Pack 12'),
array( 'value' => '1485', 'text' => 'AFSB10SU Short Snake Bite Bandage w/indicator 10cm x 4.5M'),
array( 'value' => '690', 'text' => 'AFT25SU Zinc Oxide Tape 2.5cm x 5m'),
array( 'value' => '601', 'text' => 'AGB001 First Aid Guide Booklet'),
array( 'value' => '2985', 'text' => 'AGBL AEROGUIDE Burns First Aid Card'),
array( 'value' => '2986', 'text' => 'AGEL Eye wound Treatment Card'),
array( 'value' => '603', 'text' => 'AGL001 First Aid Guide Leaflet'),
array( 'value' => '607', 'text' => 'AGNPF02 Gloves Nitrile PF Large Pair'),
array( 'value' => '1486', 'text' => 'AGNPF10 Nitrile Gloves Powder Free Large Pack 5 Pairs'),
array( 'value' => '1487', 'text' => 'AGS75 Non-Sterile Gauze Swab 7.5 x 7.5cm Pack 100'),
array( 'value' => '605', 'text' => 'AGS753SSU Gauze Swabs 7.5cm x 7.5cm (3) sterile'),
array( 'value' => '1488', 'text' => 'AGS755SSU Gauze Swab 5 Pcs White 7.5cm x 7.5cm'),
array( 'value' => '2793', 'text' => 'AHC5001 Reusable Hot & Cold Pack 29 x 12cm'),
array( 'value' => '622', 'text' => 'AII2500 Ice Pack Instant Small 80g'),
array( 'value' => '2598', 'text' => 'AII2500 BOX 96 Ice Pack Instant Small 80g BOX OF 96'),
array( 'value' => '620', 'text' => 'AII5000 Ice Pack Instant Large 240g'),
array( 'value' => '2391', 'text' => 'AKM006 FIRST AID Metal Cabinet Medium Drop Front'),
array( 'value' => '2960', 'text' => 'ALCOHOWIP155N Liv-Wipe Antibacterial Alcohol Wipes 155 per Tub'),
array( 'value' => '2067', 'text' => 'ALCOWIPES50 75% ALCOHOL WIPES PK 50'),
array( 'value' => '884', 'text' => 'AM01 CPR Face Mask'),
array( 'value' => '1489', 'text' => 'AP101 AEROPLAST PLASTIC BANDAGES Standard Strip Box 100'),
array( 'value' => '652', 'text' => 'AP10125 AEROPLAST PLASTIC BANDAGES Standard Strip 25 Pkt'),
array( 'value' => '654', 'text' => 'AP1015 AEROPLAST PLASTIC BANDAGES Standard Strip 50 Pkt'),
array( 'value' => '634', 'text' => 'AP312SU Microporous Paper Tape 1.25cm x 5m'),
array( 'value' => '1490', 'text' => 'AP325DSU Microporous Tape with Dispenser 2.5cm x 9.1M'),
array( 'value' => '1491', 'text' => 'APD100S Low Adherent Dressing Pad 10cm x 7.5cm Box 50'),
array( 'value' => '646', 'text' => 'APD100SSU Low Adherent Dressing Pad 10cm x 7.5cm'),
array( 'value' => '1492', 'text' => 'APD101S Low Adherent Dressing Pad 10cm x 10cm Box 50'),
array( 'value' => '640', 'text' => 'APD101SSU Low Adherent Dressing Pad 10cm x 10cm'),
array( 'value' => '1493', 'text' => 'APD102S Low Adherent Dressing Pad 10cm x 20cm Box 50'),
array( 'value' => '642', 'text' => 'APD102SSU Low Adherent Dressing Pad 10cm x 20cm'),
array( 'value' => '1494', 'text' => 'APD50S Low Adherent Dressing Pad 5cm x 5cm Box 50'),
array( 'value' => '644', 'text' => 'APD50SSU Low Adherent Dressing Pad 5cm x 5cm'),
array( 'value' => '1495', 'text' => 'APD75S Low Adherent Dressing Pad 7.5cm x 5cm Box 50'),
array( 'value' => '1053', 'text' => 'APD75SSU Low Adherent Dressing Pad 7.5cm x 5cm'),
array( 'value' => '3292', 'text' => 'APWC7535 Wound Closure Strips 3mm x 75mm Box 50'),
array( 'value' => '672', 'text' => 'APWC7535SU Wound Closure Strips 3mm x 75mm 5pkt'),
array( 'value' => '2016', 'text' => 'AQIUM375 Aqium 375 mls'),
array( 'value' => '666', 'text' => 'ASC13 Scissors 12.5cm Sharp / Blunt'),
array( 'value' => '648', 'text' => 'ASN096P Note Pad & Pen'),
array( 'value' => '2786', 'text' => 'ASN100-L Nitrile Finger Cots Large Box 100'),
array( 'value' => '2789', 'text' => 'ASN100-L-50 Nitrile Finger Cots Large Packet 50'),
array( 'value' => '2791', 'text' => 'ASN100-M Nitrile Finger Cots Medium Box 100'),
array( 'value' => '2790', 'text' => 'ASN100-M-50 Nitrile Finger Cots Medium Packet 50'),
array( 'value' => '674', 'text' => 'ASP100SU Splinter Probes (5)'),
array( 'value' => '664', 'text' => 'ASP12 Safety Pins (12)'),
array( 'value' => '636', 'text' => 'AT25SU Transparent Tape Microperforated 2.5cm x 5m'),
array( 'value' => '581', 'text' => 'ATB130 Emergency Thermo Blanket'),
array( 'value' => '2718', 'text' => 'AV2000 AEROPLAST PREMIUM VISUAL BANDAGES 7.5 x 2.5cm box/100'),
array( 'value' => '590', 'text' => 'AW1060SU Sodium Chloride Eye Wash Ampoule 15ml'),
array( 'value' => '1037', 'text' => 'AW1510SU Vomit Bag'),
array( 'value' => '2631', 'text' => 'AW7100 Alcohol Swab Box 100'),
array( 'value' => '517', 'text' => 'AW7100SU Alcohol Swab'),
array( 'value' => '530', 'text' => 'AW8000SU Antiseptic Wipe 200mm x 100mm'),
array( 'value' => '1496', 'text' => 'AW8110 Alcohol-Free Cleansing Wipes 200 x 100mm ENV 10'),
array( 'value' => '684', 'text' => 'AWD13SSU Wound Dressing #13'),
array( 'value' => '686', 'text' => 'AWD14SSU Wound Dressing #14'),
array( 'value' => '688', 'text' => 'AWD15SSU Wound Dressing #15'),
array( 'value' => '579', 'text' => 'AWDPB01 Dressing Pack Basic'),
array( 'value' => '1497', 'text' => 'AWP16100SU Povidone Iodine Swabs 60 x 33mm'),
array( 'value' => '1498', 'text' => 'BHB2538 Biohazard Clinical Waste'),
array( 'value' => '2149', 'text' => 'BOOC MASK DISPOSABLE FACE MASKS PKT 10'),
array( 'value' => '2156', 'text' => 'BOX 50 MASK DISPOSABLE FACE MASKS BOX 50'),
array( 'value' => '2160', 'text' => 'BOX 50 MASK-1 DISPOSABLE FACE MASKS BOX 50 BULK ORDER 20+BOXES Please contact us for your pricing'),
array( 'value' => '2844', 'text' => 'CA-05 AED A4 Wall Sticker Sign'),
array( 'value' => '2842', 'text' => 'CA-06 AED On Site Sticker'),
array( 'value' => '2863', 'text' => 'CA-08 AED in Vehicle (Small Self-Stick Vinyl) 10 × 12 cm'),
array( 'value' => '2846', 'text' => 'CA-10 AED 3D Angle Bracket Wall Mount Sign (Poly)'),
array( 'value' => '2853', 'text' => 'CA-PK1 AED Premium Prep Kit'),
array( 'value' => '2848', 'text' => 'CA-PK2 AED Basic Prep Kit'),
array( 'value' => '3867', 'text' => 'CC-60 CARDIACT Alarmed Outdoor AED Cabinet with Lock 48 x 47 x 31cm'),
array( 'value' => '567', 'text' => 'CWD001 CPR Flowchart Card CWD001'),
array( 'value' => '2244', 'text' => 'EARSAVERS Plastic Ear Savers PK 5'),
array( 'value' => '587', 'text' => 'EB001 Eye Wash Bath'),
array( 'value' => '1499', 'text' => 'EGA60 Antibacterial Hand Gel 60ml'),
array( 'value' => '2182', 'text' => 'FaceShield Full Face Shield Anti-Fog'),
array( 'value' => '2620', 'text' => 'FAR210 R2 Workplace Response First Aid Kit, Metal Wall Mount'),
array( 'value' => '2622', 'text' => 'FAR299 R2 Workplace Response Refill Pack'),
array( 'value' => '1500', 'text' => 'FCP-03 Civilian Trauma & Haemorrhage Control Wound Dressing (white) 10 x 17cm'),
array( 'value' => '1501', 'text' => 'FCP-06 Civilian Trauma & Haemorrhage Control Wound Dressing (white) 15 x 18cm'),
array( 'value' => '2578', 'text' => 'GB002 Green First Aid Bag Medium'),
array( 'value' => '630', 'text' => 'KD160 Kidney Dish Plastic 200ml'),
array( 'value' => '2128', 'text' => 'LIVTHERMO Infrared Forehead Thermometer TGA Approved'),
array( 'value' => '668', 'text' => 'ND90 Needle Disposal Unit 90ml'),
array( 'value' => '3053', 'text' => 'NEOG997 The Neo G Airflow Breathable Arm Sling'),
array( 'value' => '1502', 'text' => 'PPC60 Plastic Portion Cup 60ml'),
array( 'value' => '650', 'text' => 'PTD06 Disposable Pen Light Torch'),
array( 'value' => '2995', 'text' => 'RI001 Register of Injuries Pad'),
array( 'value' => '2971', 'text' => 'RST101 RapidStop® Tourniquet Orange'),
array( 'value' => '2987', 'text' => 'SBL Snake Bite Treatment Leaflet'),
array( 'value' => '3017', 'text' => 'SG002 Vortex Safety Spectacles Clear'),
array( 'value' => '517', 'text' => 'Alcohol Swab AW7100SU ' ),
array( 'value' => '1503', 'text' => 'SOFTT-W-R SOFTT-W Tourniquet Orange'),
array( 'value' => '872', 'text' => 'SPLINT1 18 inch Moldable Splint'),
array( 'value' => '543', 'text' => 'ST30SU Chlorhexidine Liquid 30ml'),
array( 'value' => '1841', 'text' => 'Stingoes 25 Stingoes Spray 25 ml'),
array( 'value' => '2964', 'text' => 'TPAP 1 Placebo Asthma Puffer (For Training Only)'),
array( 'value' => '1848', 'text' => 'Tuffie 5 Tuffie 5 Wipes'),
array( 'value' => '1845', 'text' => 'TuffieIPA Tuff Wipes 200 Canister'),
array( 'value' => '1530', 'text' => 'USP19 Universal Scissors 19cm'),
array( 'value' => '3004', 'text' => 'Zoll AED 3B Zoll AED 3 Battery'),
array( 'value' => '3939', 'text' => '501FS First Aid Sticker 15 x 22.5 cm'),
array( 'value' => '2857', 'text' => '501JS First Aid Signs (Small Self-Stick Vinyl) 10 × 14 cm'),
array( 'value' => '2607', 'text' => '8000-0807-01 ZOLL AED PLUS BATTERIES X 10'),
array( 'value' => '2802', 'text' => '8900-000280 Zoll CPR Uni-padz Universal (Adult/Pediatric) Electrodes for Zoll AED 3'),
array( 'value' => '2807', 'text' => '8900-0800-01 Zoll AED + CPR-D-Padz® One-Piece Electrode Pad With Real CPR Help')
));
} ```
I am aware that populate anything could assist with dynamic population but they cannot work with list columns at this point in time...

Are you using Woocommerce for your products? When passing the values to another form, can you simply use the value from column 2 to create the product name for column 1?
For example, if you have the product id from column 2, can you do the following?:
$product_id = wc_get_product( **value from column 2** );
product_name=$product_id->get_name();//pass $product_name to new form instead of grabbing column 1

Credit to GravityWiz for helping me accomplish this. They really are wizards!
My code needed to be accompanied with some javascript. I installed Gravity Forms Custom Javascript plugin and then added this code built to accompany my php code:
gform.addFilter( 'gppc_copied_value', function( value, $elem, data ) {
if ( data.source != '2611.1' || data.target == '2611.2' ) {
return value;
}
var found = jQuery( '#field_' + data.sourceFormId + '_' + parseInt( data.source ) ).find( 'option[value="' + value + '"]' ).first().text();
value = found ? found : value;
return value;
} );

Related

How to build a single 'flag' checkbox in prestashop with form helpers?

I can't figure out from official docs how to build a single checkbox element from the standard helpers. I already have the relevant boolean entity in database and I can build radios or selects as well for it, and they work.
But what I'd really like is to have a single checkbox to use as a boolean flag.
Anyone knows how?
Ok, the answer is to just use the 'switch' type: that will build a 'slider' switch on backoffice page. For future reference, I'm gonna report 3 different ways to accomplish the same task: radio, select and switch.
They have all been tested on AdminAddressesController and are bound to a custom DB boolean field called 'expo'.
//SELECT
$s_options = array(
array( 'expo' => 1, 'name' => 'Yes' ),
array( 'expo' => 0, 'name' => 'No' )
);
$temp_fields[] = array(
'type' => 'select',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'options' => array(
'query' => $s_options,
'id' => 'expo',
'name' => 'name'
)
);
//RADIO
$s_options = array(
array( 'id' => 'expo_on', 'value' => 1, 'label' => $this->l('Yes')),
array( 'id' => 'expo_off', 'value' => 0, 'label' => $this->l('No')),
);
$temp_fields[] = array(
'type' => 'radio',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'class' => 't',
'is_bool' => true,
'values' => $s_options
);
//SWITCH
$s_options = array(
array( 'id' => 'expo_on', 'value' => 1, 'label' => $this->l('Yes')),
array( 'id' => 'expo_off', 'value' => 0, 'label' => $this->l('No')),
);
$temp_fields[] = array(
'type' => 'switch',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'is_bool' => true,
'values' => $s_options
);

Prestashop Module : Add multi select dropdown

I'm working on a module and I would like to know how to add multiple dropdown with fields_options.
$this->fields_options = array(
'Test' => array(
'title' => $this->l('Test'),
'icon' => 'delivery',
'fields' => array(
'IXY_GALLERY_CREATION_OCCASION' => array(
'title' => $this->l('DropdownList'),
'type' => 'select',
'multiple' => true , // not working
'identifier' => 'value',
'list' => array(
1 => array('value' => 1, 'name' => $this->l('Test 1 ')),
2 => array('value' => 2, 'name' => $this->l('Test 2)'))
)
),
),
'description' =>'',
'submit' => array('title' => $this->l('Save'))
)
);
This is how I'm doin if you're meaning that :
$combo = $this->getAddFieldsValues();
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Title'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'select',
'lang' => true,
'label' => $this->l('Nom'),
'name' => 'nom_matiere',
'options' => array(
'query' => $combo[0],
'id' => 'id_option',
'name' => 'name'
)
),
array(
'type' => 'select',
'lang' => true,
'label' => $this->l('Nom'),
'name' => 'name',
'options' => array(
'query' => $combo[1],
'id' => 'id_option',
'name' => 'name'
)
),
),
),
'submit' => array(
'title' => $this->l('Save'),
'name' => $this->l('updateData'),
)
),
);
the answer are not correctly .. due its not only dfined the field in the database, also must capture and stored in special way the values, in this example i demostrate to store as "1,2,3,6,8" using a single field
THE COMPLETE CODE AND ALL THE STEPS ARE AT: https://groups.google.com/forum/m/?hl=es#!topic/venenuxsarisari/z8vfPsvFFjk
here i put only the most important parts..
as mentioned int he previous link, added a new fiel in the model definition, class and the table sql
this method permits to stored in the db as "1,2,3" so you can use only a single field to relation that multiple selected values, a better could be using groupbox but its quite difficult, take a look to the AdminCustomers controller class in the controllers directory of the prestachop, this has a multiselect group that used a relational table event stored in single field
then in the helper form list array of inputs define a select as:
at the begining dont foget to added that line:
// aqui el truco de guardar el multiselect como una secuencia separada por comas, mejor es serializada pero bueh
$this->fields_value['id_employee[]'] = explode(',',$obj->id_employee);
this $obj are the representation of the loaded previous stored value when go to edit ... from that object, get the stored value of the field of your multiselect, stored as "1,3,4,6"
and the in the field form helper list of inputs define the select multiple as:
array(
'type' => 'select',
'label' => $this->l('Select and employee'),
'name' => 'id_employee_tech',
'required' => false,
'col' => '6',
'default_value' => (int)Tools::getValue('id_employee_tech'),
'options' => array(
'query' => Employee::getEmployees(true), // el true es que solo los que estan activos
'id' => 'id_employee',
'name' => 'firstname',
'default' => array(
'value' => '',
'label' => $this->l('ninguno')
)
)
),
an then override the post process too
public function postProcess()
{
if (Tools::isSubmit('submitTallerOrden'))
{
$_POST['id_employee'] = implode(',', Tools::getValue('id_employee'));
}
parent::postProcess();
}
this make stored in the db as "1,2,3"

Setting default checked value in ZendFramework2 to RADIO input (QuickStart form)

Unfortunately i don`t have the exact example here, but, is similar to this:
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender'
'options' => array(
'label' => 'What is your gender ?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
)
));
How can I set a default value to this element? I tried putting this, but didn't work:
'attributes' => array(
'value' => '0'
)
Thank's! And, sorry for my poor english! I need to improve it!
You should provide the value underoption, not attribute.
LIke this :
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender'
'options' => array(
'label' => 'What is your gender ?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
'value' => 10, // here
)
));
See this link:here
Radio is just an extension of MultiCheckbox
You will need to set the checked_value within the options array
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender', // <-- missing comma here also
'options' => array(
'label' => 'What is your gender ?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
'checked_value' => 10,
)
));
You can see this in the setOptions() method of Zend\Form\Element\Checkbox which the Radio element extends.
Your syntax is correct. value key in attributes is used to set the default checked value.
You just forgot to add a comma after 'name' => 'gender'
The following code will work for you
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender',
'attributes' => array(
'value' => '0',
),
'options' => array(
'label' => 'What is your gender?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
),
));

Typo3, TCA forms view depending on the chosen option

I have made in backend a TCA form, what will change depending of the value in select field "type":
This select field contains basically the options:
rte text
url
picture
I can make the system working so, that when "rte text" is chosen, it shows specified fields for "rte text", when url is chosen it shows specified fields for "url" etc..
In my case the content is always saved in database in field "content" and the selected type is saved in field "type".
My problem is that I have not found a way to change the "content" form field / configuration, depending on the selected type.
For example when I choose "rte text" it should use for the content field this kind of configuration (rich text editor):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
and when I choose "picture" it should use for the content field this kind of configuration (file uploader):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
Is there a way to change that configuration depending of the value in the selectbox. I have tried to put two contents in an array but haven't got it working on that way.
Unfortunately you cannot change the properties of a single field via type.
You can however influence what's being displayed. So you can configure two independent fields and switch the display:
ext_tables.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => array(
//...
'type'=>'type',
//...
),
);
TCA.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'],
'types' => array(
0 => array('showitem' => 'content_rte'),
1 => array('showitem' => 'content_image'),
),
'columns' => array(
'content_rte' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
'content_upload' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
),
// ...
);
(Note: I've removed system fields like hidden, sys_language_uid etc. for simplicity's sake)

how to set up a zend multiCheckbox form field with the checkboxes checked?

i have this form:
$this->addElement (
'multiCheckbox', 'servers2',
array (
'checkedValue' => '0',
'multiOptions' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
));
the problem is that the checkedValue doesn't work for this setup, it does for a simple checkbox. I've also tried 'checkedValues' => array('1','0'), singular or plural,
but no end in sight.
any ideas?
THanks
To mark certain checkboxes as checked, try this:
$multiCheckElement->setValue(array('11.com', '3.com'));
// or
$this->addElement (
'multiCheckbox', 'servers2',
array (
'value' => array('11.com', '3.com'), // select these 2 values
'multiOptions' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
)
);
See also Zend_Form_Element_MultiCheckbox
ZF2 will require you to use value_options;
$form->add(
array(
'name' => 'servers2',
'type' => \Zend\Form\Element\MultiCheckbox::class,
'attributes' => array(
'id' => 'servers2',
'class' => 'form-control',
),
'options' => array(
'label' => 'Servers 2',
'column-size' => 'sm-10',
'label_attributes' => array('class' => 'col-sm-2'),
'twb-layout' => 'horizontal',
'value_options' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
),
)
);
To specify the checked options, as seen at
use the 'selected' => true attribute:
$options = array(
array(
'value' => '0',
'label' => 'Apple',
'selected' => false,
'disabled' => false,
'attributes' => array(
'id' => 'apple_option',
'data-fruit' => 'apple',
),
'label_attributes' => array(
'id' => 'apple_label',
),
),
array(
'value' => '1',
'label' => 'Orange',
'selected' => true,
),
array(
'value' => '2',
'label' => 'Lemon',
),
);