I’m a beginner with Zend. I have a little web site in which I can write articles for a community of users. For each article, the user is able to attach one or more file. I made a form to provide the ability to the admin to update an article.
I can display a list of input file for each file that were attached with the article.
Now I wish to diplay a link to the file on the right of my input file control.
I think I need to use decorator but I have a hard time finguring out how to make it work.
Any help on this please ?
Here is a simple way to use a View Helper in conjunction with the ViewHelper Decorator to append the link to your File element.
First, if you don’t already have a helper path set up, add this to
application.ini:Then in your path (
libraryfolder works great), create the directory treeMy/View/Helper.Create the View Helper in the above directory, for the example I am calling it
Link, so createMy/View/Helper/Link.phpThe contents of Link.php is:
Now, when you create your element, all you need to do is add the
ViewHelperdecorator, and pass some link options.Now if you use that stack of decorators for your file elements, and provide
linkOptsto the element, it will render the link after the File input. If nolinkOptsare provided, or thehrefortextelement then no link will be output after the File element.Hope that helps.