Field required conditionally

Can i put for a field display logic and logic to make it appear and be requied based on a condition

  array (
            'name' => 'questiondate_c',
            'label' => 'LBL_QUESTIONDATE',
            'logic' => [
                    'required' => [
                            'key' => 'required',
                            'modes' => ['edit', 'create'],
                            'params' => [
                                    'fieldDependencies' => [
                                            'tendertype_c'
                                    ],
                                    'activeOnFields' => [
                                            'tendertype_c' => [
                                                     'RFP'
                                                      ],
                                                       ],
                                                        ],
                                                         ]
                                                          ],
            'displayLogic' => [
                    'hide_on_type' => [
                            'key' => 'displayType',
                            'modes' => [
                                    'detail',
                                    'edit',
                                    'create',
                            ],
                            'params' => [
                                    'fieldDependencies' => [
                                             'tendertype_c',
                                    ],
                                    'targetDisplayType' => 'none',
                                    'activeOnFields' => [
                                            'tendertype_c' => ['RFI'],
                                             ]
                                              ]
                                               ]
                                                ]
          ),

i used this code from documentation but display logic only works

It depends where you are adding this, I am speculating that you are adding it to the metadata/detailviewdefs.php file, I have found that “logic” statements work best if they are in the field definition file.

as per here:

Regards

Mark

 'display' => 'none',
                 'logic' => [
                                         'hide-show-comment' => [
                                         'key' => 'displayType',
                                         'modes' => ['create','edit','detail'],
                                         'params' => [
                                                 'fieldDependencies' => ['strategic_bid_c'],
                                                 'targetDisplayType' => 'show',
                                                 'activeOnFields' => [
                                                         'strategic_bid_c' => [true],
                                                 ],
                                         ],
                                 ],
                                         'comment-required' => [
                                          'key' => 'required',
                                          'modes' => ['create','edit'],
                                          'params' => [
                                                  'fieldDependencies' => ['strategic_bid_c'],
                                                  'activeOnFields' => [
                                                         'strategic_bid_c' => [true],
                                                  ],
                                          ],
                                 ],
                 ],

i tried this code but it is only working for required

Can you please share more details on what exactly is required to help with the code suggestions. Thank you

what is required is that this field is shown and is mandatory when checkbox strategic bid is checked

Is this not working ? When the checkbox is unchecked, the field is not hidden.

Remove ‘targetDisplayType’ => ‘show’, from show hide logoc

'hide-show-comment' => [
                              'key' => 'displayType',
                               'modes' => ['create','edit','detail'],
                               'params' => [
                               'fieldDependencies' => ['strategic_bid_c'],
                                                 
                               'activeOnFields' => [
                                       'strategic_bid_c' => [true],
                                ],
                       ],

still not showing only making field required

To write code with proper formatting in these forums, you need to use a triple-backtick:

```php
$code = goes(‘here’);
```

Will show as

      $code = goes('here');

Can you please share a screenshot to understand the issue.