I have a server where I need to store some images. Now the images can be either uploaded or created on the fly let us say just by adding some text to some default picture(So I made a file MakenewForm.php
for that) . The table in my database stores filename on the local filesystem. Now upload is simple, I can just use the default _new action for that. For creating picture, I made a new action, say makenew
. new
and makenew
both are diplayed on the list view. I copied newSuccess.php
to makenewSuccess.php
. Now I want a different set of submit buttons for them. I can't seem to figure out how to do that. All I see is this:
<div id="sf_admin_content">
<?php include_partial('poster/form', array('poster' => $poster, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
</div>
I don't know what is $configuration and what is $helper. Can someone tell me about them? Which one do I need to change and How?
Also, as you can infer, the submit action of the new
action only needs to do a $form->save()
but the submit action of makenew
needs to take all the text input and write an image file(let's say using imagejpeg)
I need some pointers towards achieving this.
I hope to well focus about what you are looking for.
About
$configuration
and$helper
, as you can find incache\mypplication\dev\modules\autoMymodule\actions\actions.class.php
the functionpreExecute()
is used also to create them:These classes are in
apps\docdesk\modules\mymodule\lib
. You can find base classes incache\mypplication\dev\modules\autoMymodule\lib
. Have a look to these base classes to understand how are used and so which configuration functions and helper functions the admin generator makes available.To deal with your new action, I don't know the feature you're developing so I'll try to imagine two possible scenarios. You can use only a form switching your functions of upload/create picture trough a custom widget, overriding the template
_form.php
, called in your snippet, and the new action and so on or, this is the way you're following, create a completely separate action, form and all needed templates. So in your makenewSucces.php you can include a template _makeform.php called with<?php include_partial('poster/makeform', array('poster' => $poster, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
Of course you have to put the template
_makeform.php
inapps\docdesk\modules\mymodule\template
as each new or overrided one.I don't well understand your trouble about the image saving... I suppose you're asking for the saving chain of an image and how and where you can manage what you need. To add the widget to upload an image inside your
PosterForm
class you can use a snippet like this where we supposephoto
as widget name, according with a schema fieldphoto: { type: varchar(255), required: true }
, that is of course to customize:Note that my setting for
upload_image_dir
is%SF_UPLOAD_DIR%/images/
Symfony will upload and save the image for you!
Then you can override the
doSave
function, according to your needs, putting the same one yet in yourPosterForm
class:Finally to remove your image, that is the file, when you delete the object, that is the db record where the image name is a field, you have to put this code in your model class
Poster
:I hope this can help you.