Skip to content
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

Fix the 'attr' configuration in custom forms #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix the 'attr' configuration in custom forms #103

wants to merge 1 commit into from

Conversation

kr1-ch
Copy link

@kr1-ch kr1-ch commented May 30, 2017

If you define the style attr this way:

$view->vars['attr'] = array('style' => 'opacity: 0;width: 0; max-width: 0; height: 0; max-height: 0;');

Then the attr options are not available on forms fields where you use the CroppableImageType, for example:

->add('image1', CroppableImageType::class, array(
    'attr' => array('class'=>'block1'),
    'uploadConfig' => array(
        'uploadRoute' => 'comur_api_upload', 		//optional
        'uploadUrl' => $entity->getUploadRootDir(),       // required - see explanation below (you can also put just a dir path)
        'webDir' => $entity->getUploadDir(),				// required - see explanation below (you can also put just a dir path)
        'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 	//optional
        'libraryDir' => null, 						//optional
        'libraryRoute' => 'comur_api_image_library', //optional
        'showLibrary' => true, 						//optional
        'saveOriginal' => 'originalImage',			//optional
        'generateFilename' => true			//optional
    ),
    'cropConfig' => array(
        'minWidth' => 588,
        'minHeight' => 300,
        'aspectRatio' => true, 				//optional
        'cropRoute' => 'comur_api_crop', 	//optional
        'forceResize' => false, 			//optional
        'thumbs' => array( 					//optional
            array(
                'maxWidth' => 180,
                'maxHeight' => 400,
                'useAsFieldImage' => true  //optional
            )
        )
    )
))

If you define the attr "style" this way: $view->vars['attr'] = array('style' => 'opacity: 0;width: 0; max-width: 0; height: 0; max-height: 0;');
Then the attr options are not available on forms fields where you use the CroppableImageType, for example:

->add('image1', CroppableImageType::class, array(
                'attr' => array('class'=>'block1'),
                'uploadConfig' => array(
                    'uploadRoute' => 'comur_api_upload', 		//optional
                    'uploadUrl' => $entity->getUploadRootDir(),       // required - see explanation below (you can also put just a dir path)
                    'webDir' => $entity->getUploadDir(),				// required - see explanation below (you can also put just a dir path)
                    'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 	//optional
                    'libraryDir' => null, 						//optional
                    'libraryRoute' => 'comur_api_image_library', //optional
                    'showLibrary' => true, 						//optional
                    'saveOriginal' => 'originalImage',			//optional
                    'generateFilename' => true			//optional
                ),
                'cropConfig' => array(
                    'minWidth' => 588,
                    'minHeight' => 300,
                    'aspectRatio' => true, 				//optional
                    'cropRoute' => 'comur_api_crop', 	//optional
                    'forceResize' => false, 			//optional
                    'thumbs' => array( 					//optional
                        array(
                            'maxWidth' => 180,
                            'maxHeight' => 400,
                            'useAsFieldImage' => true  //optional
                        )
                    )
                )
            ))
@comur
Copy link
Owner

comur commented May 23, 2019

Hi @Kr118218
did you check that it works when you omit attr field in field conf ? If yes I can merge
Thanks

@kr1-ch
Copy link
Author

kr1-ch commented May 24, 2019

Hi @comur,

Thank you for the reply.

I don't remember if I tested this scenario two years ago. I'll do it.

Are you going to update the project again?

@kr1-ch kr1-ch changed the title Update CroppableImageType.php Fix the 'attr' configuration in custom forms May 24, 2019
@comur
Copy link
Owner

comur commented May 25, 2019

Hi
Yes I will do a big update soon (I hope next week) so I’m looking for issues to fix and enchancement to add into the next release
Thx for your help to make it better ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants