SSL Labs ScoreSecurityHeaders.io ScoreHSTS Preloaded

Log in to participate

There is no cost to join RicheyWeb, and membership is a requirement to submit bug reports and participate in the support forums.

× Extension Discussions

Field -subform check if empty

More
2 weeks 4 days ago - 2 weeks 4 days ago #3959 by GetToNet
What am I doing wrong?

I'd like to add the conditional, and not to output anything if the field is not set.
So, in my single article template override I have tried
foreach($this->item->jcfields as $jcfield)
     {
          $item->jcFields[$jcfield->name] = $jcfield;
     }
$myCustomFields = array();
    foreach($this->item->jcfields as $field) {
        $myCustomFields[$field->name] = $field->value;
    }

and then
if (isset($myCustomFields['mysubformfield']) and !empty($myCustomFields['mysubformfield']))  {
//do what needs to be done if the field is set
}

but I always get the output even if none of the fields in subform is set..
Last edit: 2 weeks 4 days ago by GetToNet.

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #3960 by GetToNet
Subform settings:
Load template: No
Multiple: False

Form source:
<form>
    <fieldset name="feedback" label="Feedback" description="Select feedback image, Enter feedback content, person name and title.">
        <field name="feedback_image" type="media" label="Image" />
		<field name="feedback_content" type="textarea" label="Feedback content" />
		<field name="feedback_sig_1" type="text" label="Person name" />
		<field name="feedback_sig_2" type="text" label="Person title" />
    </fieldset>
</form>

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #3961 by GetToNet
Solved....if there's a better way, let me know..
$feedback_json =  $item->jcFields['feedback']->rawvalue;
	$feedback = json_decode($feedback_json, true);
	if(array_filter($feedback)) {
		$feedback_exists = true;
	}

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #3962 by michael
array_filter seems like a great solution. Right on figuring that out! I just got done working on my truck brakes, or I would have answered earlier.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Powered by Kunena Forum