How to Set Raw, html text for checkbox – radio labels when used symfony form builder

As default, Symfony 4 does not allow the set raw label text for form elements. I needed this when I want to show terms of use checkbox in a form. I found a workaround solution to accomplish this.

 

FormType Source Code:

/* ... */

class RegistrationFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('termsOfUse', CheckboxType::class, [
            'mapped' => false,
            'label' => 'I agree and accept #TERMS_OF_USE_LINK#',
            'constraints' => new IsTrue(),
        ]);

        /* ... */
    }
}


Twig Template Source Code

{{ form_start(form) }}

{% set termsOfUseFormGroup %}
    {{ form_row(form.termsOfUse) }}
{% endset %}

{{ termsOfUseFormGroup|replace({'#TERMS_OF_USE_LINK#':'<a href="#">Terms of Use</a>'})|raw }}

{{ form_end(form) }}

To explain briefly, I set rendered terms of use form group content (which is {{ form_row(form.termsOfUse) }}) to a variable (which is termsOfUseFormGroup) and replace #TERM_OF_USE_LINK# string to a link.

Wamp Server Yüklerken Eksik VCRUNTIME140.dll ve MSVCR110.dll Dosyaları Hatası

Wamp Server (bendeki versiyon WampServer 64 bits (x64) 3.0.6) yüklerken ve çalıştırmaya çalışırken 2 dll dosyası eksik hatası veriyor. Bu dll’ler:

  • VCRUNTIME140.dll (yükleme esnasında)
  • MSVCR110.dll (çalıştırma esnasında)

Bu hatayı gidermek Wamp Server’ı sağlıklı yüklemek için:
1) Önceki Wamp Server programını kaldırın
2) Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) yüklemesini yapın: https://www.microsoft.com/en-us/download/details.aspx?id=48145
3) Wamp Server’ı tekrar baştan kurun

Update form with UniformJs after any changes on uniform elements

When you make any changes on a form with UniformJs and if you make changes on the form such uncheck a checkbox, you must update your changes on uniform elements.

// make a checkbox (uniform element) checked
$('#checkbox').prop('checked',true);

// update uniform element
$.uniform.update('#checkbox');

// or you can make update for all uniform elements in the form
$.uniform.update();

How to create a cookie which never expire using Codeigniter

Maximum value of cookie expiration time is 2147483647 (2^31 – 1 = 2147483647 = 2038-01-19 04:14:07) [see: RFC 2616, 14.6 Age]

So the example code snippet:

// substracting current time from last exp. time because CI adds current time to the value
$unexpired_cookie_exp_time = 2147483647 - time();

$cookie = array(
	'name' => 'cookie_name',
	'value' => 'cookie_value',
	'expire'=> $unexpired_cookie_exp_time
);

$CI->input->set_cookie($cookie);