Skip to content

Instantly share code, notes, and snippets.

@lcharette
Last active April 16, 2019 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcharette/41a950ac6d39f56f62de81c245f6aafb to your computer and use it in GitHub Desktop.
Save lcharette/41a950ac6d39f56f62de81c245f6aafb to your computer and use it in GitHub Desktop.
{% for field in user.profileFields %}
<div class="row">
<div class="alert alert-info">
{{ translate('USER.PROFILE.' ~ field.slug|upper) }}
</div>
</div>
{% endfor %}
</div>
<div class="col-xs-6">
{% for field in user.profileFields %}
<div class="row">
<div class="alert {% if fields.value == 'yes' %}alert-success{% elseif fields.value starts with 'yes' %}alert-warning{% elseif fields.value == 'no' %} alert-danger{% else %}alert-info{% endif %}">
{{ fields.value }}
</div>
</div>
{% endfor %}
// ...
$user = User::with('profileFields')->get();
return $this->ci->view->render($response, 'foo.html.twig', [
'user' => $user
]);
return [
'USER' => [
'PROFILE' => [
'LOCATION' => 'User location',
'GENDER' => 'User gender',
'OCCUPATION' => 'User occupation',
]
]
];
{
"location" : {
"validators" : {
"length" : {
"label" : "USER.PROFILE.LOCATION",
"min" : 1,
"max" : 255,
"message" : "VALIDATE.LENGTH_RANGE"
}
},
"form": {
"type": "text",
"label": "LOCATION",
"icon": "fa-globe"
}
},
"occupation" : {
"validators" : {
"length" : {
"label" : "USER.PROFILE.OCCUPATION",
"min" : 1,
"max" : 255,
"message" : "VALIDATE.LENGTH_RANGE"
}
},
"form": {
"type": "textarea",
"label": "OCCUPATION",
"icon": "fa-briefcase"
}
},
"gender" : {
"validators" : {},
"form": {
"type": "select",
"label": "USER.PROFILE.GENDER",
"icon": "fa-transgender",
"options" : {
"1" : "GENDER.MALE",
"2" : "GENDER.FEMALE",
"3" : "GENDER.NEUTRAL"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment