PHP code example of simplethings / form-extra-bundle

1. Go to this page and download the library: Download simplethings/form-extra-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

simplethings / form-extra-bundle example snippets

 php


public function registerBundles()
{
    // ...
    new SimpleThings\FormExtraBundle\SimpleThingsFormExtraBundle(),
    // ...
}
 php

// ...
$builder->add('recaptcha', 'formextra_recaptcha');
// ...
 php

// ...
$builder->add('recaptcha', 'formextra_recaptcha', array(
    'widget_options' => array(
        'theme' => 'white', // blackglass, clean, red is the predefined themes.
    ),
));
// ...
 php

// ...
$builder->add('username', 'formextra_plain');
// ...
 php

class Document
{
    // temporary field, used in the form, to move new attachments to persistence
    private $newAttachment;
    // persistent array with all attachments.
    private $attachments;

    public function getNewAttachment()
    {
        $files = array();
        foreach ($this->attachments AS $attachment) {
            $files[] = $attachment->getFilename();
        }
        return $files;
    }

    public function setNewAttachment(File $newAttachment = null)
    {
        $this->newAttachment = $newAttachment;
    }

    public function moveNewAttachment()
    {
        // code to move file and 
 php

$builder->add('newAttachment', 'formextra_fileset', array(
    'type' => 'file',
));
 php

// ...
$builder->add('body', 'textarea', array(
    'label' => 'some message',
    'translation_domain' => 'form_extra',
));
// ...
 php

// ...
$builder->add('body', 'textarea', array(
    'label' => 'some message',
    'help'  => 'some usefull help message'
));
// ...
 php

// ...
$builder->get('body')->prependNormTransformer(new HtmlEntitiesTransformer(ENT_COMPAT, true));
// ...
 php

// ...
// This will allow <p> tags.
$builder->get('body')->prependNormTransformer(new StripTagsTransformer('<p>'));
// ...