-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use description from schema if available when using entityForm #12971
Use description from schema if available when using entityForm #12971
Conversation
(Standard links)
|
@@ -1292,7 +1292,7 @@ public function addDateRange($name, $from = '_from', $to = '_to', $label = 'From | |||
* | |||
* Return string | |||
*/ | |||
private function getApiAction() { | |||
protected function getApiAction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing visibility can break forms that extend the parent - I did a grep & found a few places that implement function getApiAction() with 'protection' but none with private so I guess that is fine. Also it's a bit intuitive that changing up from private is probably ok since private is not available to override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so basically we're making it accessible from child classes which is needed to get the right API action to retrieve the metadata.
19e56f8
to
59f04ea
Compare
@mattwire So this is a good thing to do. I note a few things
You can see description is not translated - I think maybe it should be @colemanw @mlutfy - any concerns if we add ts around description field when generating DAOs |
CRM/Core/Form/EntityFormTrait.php
Outdated
@@ -221,4 +222,21 @@ protected function isDeleteContext() { | |||
return ($this->_action & CRM_Core_Action::DELETE); | |||
} | |||
|
|||
protected function setEntityFieldsMetadata() { | |||
foreach ($this->entityFields as $field => &$props) { | |||
if ($props['not-auto-addable']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may need to change to
if ($props['not-auto-addable']) { | |
if (!empty($props['not-auto-addable'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Done :-)
59f04ea
to
d5e4784
Compare
I didn't want to touch the actual descriptions until we got this PR into shape and merged. And I think there will be situations where there is a description in the schema that we don't want to show on the form but may popup elsewhere (eg. API explorer). So blocking this particular description was more of a proof of concept to show we can override/hide them if desired. |
This relates to the attempt here civicrm#12971 to use description directly in the Entity Forms & questions as to whether it is translated. Currently they are not but there seems like no downside in translating them
If we can resolve #13005 then we can merge this |
@mattwire the other PR is merged so merging this so we can 'mature it up' |
Overview
Further development of entityForm.
This adds the (default) ability to automatically show the description from the entity schema instead of hardcoding in the entityFields property on the class.
Before
Converting to entityForm requires moving description from tpl to setEntityFields() in form class.
After
Converting to entityForm requires verifying metadata description in xml schema and updating if necessary. Description does not need to be hardcoded in class.
Technical Details
We get the metadata using API.getfield. Technically this means we are now calling this twice (as it is also called by addField later on).
Comments
@mlutfy Please could you comment from a translation perspective.. ie. do the schema elements get translated?
@eileenmcnaughton Next stage of entityForm...