-
Notifications
You must be signed in to change notification settings - Fork 31
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
Custom classes to control wrapper #9
Comments
👍 |
Why not use the |
That won't work if i have multiple controls with same type, but only one or two of those needs custom styles. Maybe later few other controls would need those styles also, but i don't want every same type control to have that style. E.g. thee text controls: address, postal code and state. First can be with class |
See, those are not the same type of controls and wouldn't be my recommended method of handling that. For your specific example, I'd actually build an "address" control, which would have the |
Here's a quick address control example: <?php
class ButterBean_Control_Address {
public $type = 'address';
public function to_json() {
parent::to_json();
$this->json['address'] = array(
'label' => 'address',
'value' => $this->get_value( 'street' ),
'field_name' => $this->get_field_name( 'street' )
);
$this->json['state'] = array(
'label' => 'State',
'value' => $this->get_value( 'state' ),
'field_name' => $this->get_field_name( 'state' )
);
$this->json['zip'] = array(
'label' => 'ZIP Code',
'value' => $this->get_value( 'zip_code' ),
'field_name' => $this->get_field_name( 'zip_code' )
);
}
public function get_template() { ?>
<label>
<span class="butterbean-label">{{ data.address.label }}</span>
<input type="text" value="{{ data.address.value }}" name="{{ data.address.field_name }}" />
</label>
<label>
<span class="butterbean-label">{{ data.state.label }}</span>
<input type="text" value="{{ data.state.value }}" name="{{ data.state.field_name }}" />
</label>
<label>
<span class="butterbean-label">{{ data.zip.label }}</span>
<input type="text" value="{{ data.zip.value }}" name="{{ data.zip.field_name }}" />
</label>
<?php }
} |
Anyway, what I'm getting at here is that all controls of a specific type should be uniform. They should look and behave in the same way. If you have a type that's already handled but want it to be different, you should extend the |
Thanks for the example! I was needing this exact thing. |
Thanks for example, that will do the trick in this specific situation. Like m-e-h said above, some utility class(es) would be nice, since there could be situation where somebody want's let's say two email fields side by side. In that case, making custom control for that is just overkill. At least in my opinion. |
I second @m-e-h's suggestion on |
+1 for additional classes, @justintadlock |
Hi, I tested this framework and it is awesome!
One thing i'm kinda needing and hoping, is possibility to add custom classes for control wrapper divs. That would allow more versatile usage, since it would make e.g. adding styles for 50/50 grid or separators much mode easier. Now you need to target every control with it's id, and that's somewhat tedious.
The text was updated successfully, but these errors were encountered: