xpertbot / craft-wheelform

Craft CMS 4 Form with Database integration
MIT License
66 stars 32 forks source link

Field id always null #269

Closed alanski66 closed 2 years ago

alanski66 commented 2 years ago

I see from this issue that field id is meant to be available in the templates. If i dump it out its always null

object(wheelform\services\FieldService)#2080 (7) {
  ["type":"wheelform\services\FieldService":private]=>
  string(4) "list"
  ["options":"wheelform\services\FieldService":private]=>
  object(stdClass)#2076 (3) {
    ["label"]=>
    string(15) "Improvement two"
    ["containerClass"]=>
    string(0) ""
    ["fieldClass"]=>
    string(0) ""
  }
  ["order":"wheelform\services\FieldService":private]=>
  string(1) "9"
  ["required":"wheelform\services\FieldService":private]=>
  string(1) "0"
  ["name":"wheelform\services\FieldService":private]=>
  string(14) "ImprovementTwo"
  ["value":"wheelform\services\FieldService":private]=>
  string(0) ""
  ["field_id":"wheelform\services\FieldService":private]=>
  NULL
}

Is it available to twig?

xpertbot commented 2 years ago

field_id being null is the default behavior, the field_id gets generated on the fly the first time you access it. calling $field->getFieldId() should retrieve it correctly

alanski66 commented 2 years ago

But in twig? :)

xpertbot commented 2 years ago

in twig templates you should be able to do field.fieldId() when inside the loop for field in form.fields

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.