Skip to content
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

Added label to system.xml #3577

Closed
wants to merge 5 commits into from
Closed

Added label to system.xml #3577

wants to merge 5 commits into from

Conversation

kyrena
Copy link
Contributor

@kyrena kyrena commented Oct 4, 2023

Description

This PR add the label field to system.xml, this is an extract of #2739:

image

XML of the preview:

<head>
	<label>Crash test</label>
	<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
	<sort_order>1001</sort_order>
	<show_in_default>1</show_in_default>
	<show_in_website>1</show_in_website>
	<show_in_store>1</show_in_store>
</head>
<label_1>
	<label>label</label>
	<value>Pouet</value>
	<frontend_type>label</frontend_type>
	<frontend_model>adminhtml/system_config_form_field_label</frontend_model>
	<sort_order>1002</sort_order>
	<show_in_default>1</show_in_default>
	<show_in_website>1</show_in_website>
	<show_in_store>1</show_in_store>
</label_1>
<labelbold_2>
	<label>label bold</label>
	<value>Pouet Pouet</value>
	<bold>1</bold>
	<frontend_type>label</frontend_type>
	<frontend_model>adminhtml/system_config_form_field_label</frontend_model>
	<sort_order>1003</sort_order>
	<show_in_default>1</show_in_default>
	<show_in_website>1</show_in_website>
	<show_in_store>1</show_in_store>
</labelbold_2>

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the Component: Adminhtml Relates to Mage_Adminhtml label Oct 4, 2023
@fballiano
Copy link
Contributor

will test asap

@fballiano
Copy link
Contributor

Screenshot 2023-10-04 alle 14 01 21

wouldn't it be better to use the frontend_type instead of the frontend_model?

@fballiano
Copy link
Contributor

also, I don't love the "store view" indicator for something that cannot change at a store view level, but I don't know if there's a way around that.

Screenshot 2023-10-04 alle 14 02 33

@kyrena
Copy link
Contributor Author

kyrena commented Oct 4, 2023

Oh yes, true, I can remove it.

@kiatng
Copy link
Contributor

kiatng commented Oct 5, 2023

How to use Use Website?
image

@luigifab
Copy link
Contributor

luigifab commented Oct 5, 2023

loool, good catch! This will fix them: $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue()->unsPath();

@elidrissidev
Copy link
Member

wouldn't it be better to use the frontend_type instead of the frontend_model?

<frontend_type> alone should be enough.

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
@luigifab luigifab requested a review from kiatng October 21, 2023 13:40
fballiano

This comment was marked as resolved.

@fballiano
Copy link
Contributor

EDIT: apologize, my comment was wrong.

the current state of the PR is this:
Screenshot 2023-10-21 alle 15 13 14

but it still requires a frontend_model, which I don't really like

@fballiano fballiano self-requested a review October 21, 2023 14:14
@ma4nn
Copy link
Contributor

ma4nn commented Oct 27, 2023

Why not use the existing Varien_Data_Form_Element_Label or Varien_Data_Form_Element_Note?

@kyrena
Copy link
Contributor Author

kyrena commented Oct 27, 2023

Because we must pass config data from $element->getFieldConfig():

$label->setValue($field->value);
$label->setBold(!empty($field->bold));

@ma4nn
Copy link
Contributor

ma4nn commented Oct 27, 2023

ok understood the idea now 👍 (the Varien_Data_Form_Element_Label can also handle the value but not the bold option)

But wouldn't it make more sense then to have a more flexible label with HTML values allowed in general (so the bold attribute is not necessary)? E.g. perhaps use

<frontend_type>note</frontend_type>
<frontend_model>adminhtml/system_config_form_field_label</frontend_model>

and then do a $element->setText($field->value);?

Though I agree with @fballiano that the naming is not really intuitive..

@fballiano
Copy link
Contributor

IMHO the current implementation is a bit too limited:

  • I think it should support full HTML as @ma4nn pointed out, removing the need for ->setBold
  • using fontend_type and not requiring a frontend_model would seem more intuitive to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants