Pregunta

Hi as in the main question? How can i do a file filed type hidden ? in builder i can do:

$builder->add('file', 'file', array()

when i want my form field to by file type or

$builder->add('file', 'hidden', array()

when i want my form field to be hidden

but how can i bring this to together ? so the file is hidden and aslo a field type ? Is there any way to use two field types in one field ? Or do anyone have some idea about how can i hide field type in my form ?

Also available answers are how to valid hidden type as the field file type?

$builder->add('file', 'hidden', array()
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'MyDriveBundle\Model\UploadedFile',
        ));
    }

will it work like this and accept files only ? if UploadedFile got:

protected $file;
¿Fue útil?

Solución

You can add extra css to your field with attr :

$builder->add('file', 'fie', array('label' => 'My file', 'attr' => array('style' => 'display:none')));

or

//CSS File

.notvisibleclass{
    display:'none'; }

//Form file

$builder->add('file', 'fie', array('label' => 'My file', 'attr' => array('class' => 'novisibleclass')));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top