<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Symfony Form: записываем относительный путь для файлов в БД	</title>
	<atom:link href="https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/feed/" rel="self" type="application/rss+xml" />
	<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=symfony-12-form-save-relative-file-path</link>
	<description>О разработке веб-приложений на Symfony</description>
	<lastBuildDate>Mon, 04 May 2009 08:26:17 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>
		By: ingvar		</title>
		<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/comment-page-1/#comment-1964</link>

		<dc:creator><![CDATA[ingvar]]></dc:creator>
		<pubDate>Mon, 04 May 2009 08:26:17 +0000</pubDate>
		<guid isPermaLink="false">http://tigor.com.ua/blog/?p=697#comment-1964</guid>

					<description><![CDATA[Вот такой должен быть пример. Это класс NewsForm. Этого вполне достаточно.

class NewsForm extends BaseNewsForm
{
  public function configure()
  {
    parent::configure();

    $this-&gt;path = &#039;news/&#039; . date(&#039;Y/m/d&#039;);

    $this-&gt;setWidget(&#039;file&#039;, new sfWidgetFormInputFile(),);

    $this-&gt;validatorSchema[&#039;file&#039;] = new sfValidatorFile(array(
      &#039;required&#039;   =&gt; false,
      &#039;path&#039;       =&gt; $this-&gt;path,
      &#039;mime_types&#039; =&gt; &#039;web_images&#039;,
    ))


    $this-&gt;setWidget(&#039;image_url_1&#039;, sfCpanelForm::getWidgetFormInputFileEditable());
    $this-&gt;validatorSchema[&#039;image_url_1&#039;] = sfCpanelForm::getsfValidatorFile($this-&gt;path, 1024000);
  }


  public function saveFile($field, $filename = null, sfValidatedFile $file = null)
  {
    return &#039;/uploads/&#039; . $this-&gt;path . &#039;/&#039; . parent::saveFile($field, $filename, $file);
  }]]></description>
			<content:encoded><![CDATA[<p>Вот такой должен быть пример. Это класс NewsForm. Этого вполне достаточно.</p>
<p>class NewsForm extends BaseNewsForm<br />
{<br />
  public function configure()<br />
  {<br />
    parent::configure();</p>
<p>    $this->path = &#8216;news/&#8217; . date(&#8216;Y/m/d&#8217;);</p>
<p>    $this->setWidget(&#8216;file&#8217;, new sfWidgetFormInputFile(),);</p>
<p>    $this->validatorSchema[&#8216;file&#8217;] = new sfValidatorFile(array(<br />
      &#8216;required&#8217;   => false,<br />
      &#8216;path&#8217;       => $this->path,<br />
      &#8216;mime_types&#8217; => &#8216;web_images&#8217;,<br />
    ))</p>
<p>    $this->setWidget(&#8216;image_url_1&#8217;, sfCpanelForm::getWidgetFormInputFileEditable());<br />
    $this->validatorSchema[&#8216;image_url_1&#8217;] = sfCpanelForm::getsfValidatorFile($this->path, 1024000);<br />
  }</p>
<p>  public function saveFile($field, $filename = null, sfValidatedFile $file = null)<br />
  {<br />
    return &#8216;/uploads/&#8217; . $this->path . &#8216;/&#8217; . parent::saveFile($field, $filename, $file);<br />
  }</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: masterY0da		</title>
		<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/comment-page-1/#comment-1949</link>

		<dc:creator><![CDATA[masterY0da]]></dc:creator>
		<pubDate>Sun, 03 May 2009 07:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://tigor.com.ua/blog/?p=697#comment-1949</guid>

					<description><![CDATA[меня интересует точное расположение этих файлов, кторые редактируются, потому как в своих я правлю ,а такое чувство что они даже не выполняются :(
/lib/form/ContentViewForm.class.php
и 
/lib/form/baseFormpropel.class.php
код в 1
class ContentViewForm extends BaseContentViewForm
{
  parent::configure();

    $this-&#062;path = &#039;view/&#039; . date(&#039;Y/m/d&#039;);

    $this-&#062;setWidget(&#039;file&#039;, new sfWidgetFormInputFileEditable(array(
      &#039;file_src&#039;       =&#062; &#039;-foo-&#039;,
      &#039;is_image&#039;       =&#062; true
    )));  

    $this-&#062;validatorSchema[&#039;file&#039;] = new myValidatorFile(array(
      &#039;required&#039;   =&#062; false,
      &#039;mime_types&#039; =&#062; &#039;web_images&#039;,
      &#039;path&#039;       =&#062; sfConfig::get(&#039;sf_upload_dir&#039;) . $this-&#062;path,
    ));

    $this-&#062;validatorSchema-&#062;setOption(&#039;allow_extra_fields&#039;, true);
    $this-&#062;validatorSchema-&#062;setOption(&#039;filter_extra_fields&#039;, false);
  }

  public function saveFile($field, $filename = null, sfValidatedFile $file = null)
  {
    return &#039;/uploads/&#039; . $this-&#062;path . &#039;/&#039; . parent::saveFile($field, $filename, $file);
  }


}
во втром

abstract class BaseFormPropel extends sfFormPropel
{
  public function setup()
  {
  }
  protected function removeFile($field)
  {
    if (!$this-&#062;validatorSchema[$field] instanceof sfValidatorFile)
    {
      throw new LogicException(sprintf(&#039;You cannot remove the current file for field
          &quot;%s&quot; as the field is not a file.&#039;, $field));
    }

    $column = call_user_func(array(constant(get_class($this-&#062;object).&#039;::PEER&#039;), &#039;translateFieldName&#039;),
        $field, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
    $getter = &#039;get&#039;.$column;

    if (($directory = sfConfig::get(&#039;sf_web_dir&#039;)) &#038;&#038; is_file($directory.$this-&#062;object-&#062;$getter()))
    {
      unlink($directory.$this-&#062;object-&#062;$getter());
    }
  }

}]]></description>
			<content:encoded><![CDATA[<p>меня интересует точное расположение этих файлов, кторые редактируются, потому как в своих я правлю ,а такое чувство что они даже не выполняются 🙁<br />
/lib/form/ContentViewForm.class.php<br />
и<br />
/lib/form/baseFormpropel.class.php<br />
код в 1<br />
class ContentViewForm extends BaseContentViewForm<br />
{<br />
  parent::configure();</p>
<p>    $this-&gt;path = &#8216;view/&#8217; . date(&#8216;Y/m/d&#8217;);</p>
<p>    $this-&gt;setWidget(&#8216;file&#8217;, new sfWidgetFormInputFileEditable(array(<br />
      &#8216;file_src&#8217;       =&gt; &#8216;-foo-&#8216;,<br />
      &#8216;is_image&#8217;       =&gt; true<br />
    )));  </p>
<p>    $this-&gt;validatorSchema[&#8216;file&#8217;] = new myValidatorFile(array(<br />
      &#8216;required&#8217;   =&gt; false,<br />
      &#8216;mime_types&#8217; =&gt; &#8216;web_images&#8217;,<br />
      &#8216;path&#8217;       =&gt; sfConfig::get(&#8216;sf_upload_dir&#8217;) . $this-&gt;path,<br />
    ));</p>
<p>    $this-&gt;validatorSchema-&gt;setOption(&#8216;allow_extra_fields&#8217;, true);<br />
    $this-&gt;validatorSchema-&gt;setOption(&#8216;filter_extra_fields&#8217;, false);<br />
  }</p>
<p>  public function saveFile($field, $filename = null, sfValidatedFile $file = null)<br />
  {<br />
    return &#8216;/uploads/&#8217; . $this-&gt;path . &#8216;/&#8217; . parent::saveFile($field, $filename, $file);<br />
  }</p>
<p>}<br />
во втром</p>
<p>abstract class BaseFormPropel extends sfFormPropel<br />
{<br />
  public function setup()<br />
  {<br />
  }<br />
  protected function removeFile($field)<br />
  {<br />
    if (!$this-&gt;validatorSchema[$field] instanceof sfValidatorFile)<br />
    {<br />
      throw new LogicException(sprintf(&#8216;You cannot remove the current file for field<br />
          &#8220;%s&#8221; as the field is not a file.&#8217;, $field));<br />
    }</p>
<p>    $column = call_user_func(array(constant(get_class($this-&gt;object).&#8217;::PEER&#8217;), &#8216;translateFieldName&#8217;),<br />
        $field, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);<br />
    $getter = &#8216;get&#8217;.$column;</p>
<p>    if (($directory = sfConfig::get(&#8216;sf_web_dir&#8217;)) &amp;&amp; is_file($directory.$this-&gt;object-&gt;$getter()))<br />
    {<br />
      unlink($directory.$this-&gt;object-&gt;$getter());<br />
    }<br />
  }</p>
<p>}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ingvar		</title>
		<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/comment-page-1/#comment-1945</link>

		<dc:creator><![CDATA[ingvar]]></dc:creator>
		<pubDate>Sat, 02 May 2009 11:47:36 +0000</pubDate>
		<guid isPermaLink="false">http://tigor.com.ua/blog/?p=697#comment-1945</guid>

					<description><![CDATA[Покажите полный пример Вашего кода.]]></description>
			<content:encoded><![CDATA[<p>Покажите полный пример Вашего кода.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: dmitry		</title>
		<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/comment-page-1/#comment-1924</link>

		<dc:creator><![CDATA[dmitry]]></dc:creator>
		<pubDate>Thu, 30 Apr 2009 16:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://tigor.com.ua/blog/?p=697#comment-1924</guid>

					<description><![CDATA[я еще новичок :)
сделал по вашему примеру, чето как писал файлы в uploads так и пишет...и ошибок никаких не выводит..
подскажите мож настроить чтото надо]]></description>
			<content:encoded><![CDATA[<p>я еще новичок 🙂<br />
сделал по вашему примеру, чето как писал файлы в uploads так и пишет&#8230;и ошибок никаких не выводит..<br />
подскажите мож настроить чтото надо</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ingvar		</title>
		<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/comment-page-1/#comment-1099</link>

		<dc:creator><![CDATA[ingvar]]></dc:creator>
		<pubDate>Sun, 22 Feb 2009 18:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://tigor.com.ua/blog/?p=697#comment-1099</guid>

					<description><![CDATA[Верное замечание :), спасибо, подправил.]]></description>
			<content:encoded><![CDATA[<p>Верное замечание :), спасибо, подправил.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sergey		</title>
		<link>https://tigor.com.ua/blog/2008/12/11/symfony-12-form-save-relative-file-path/comment-page-1/#comment-1097</link>

		<dc:creator><![CDATA[sergey]]></dc:creator>
		<pubDate>Sun, 22 Feb 2009 09:59:14 +0000</pubDate>
		<guid isPermaLink="false">http://tigor.com.ua/blog/?p=697#comment-1097</guid>

					<description><![CDATA[а ничего что new sfWidgetFormInputFileEditable требует обязательный параметр file_src ?
пример не соответствует реально работающей форме]]></description>
			<content:encoded><![CDATA[<p>а ничего что new sfWidgetFormInputFileEditable требует обязательный параметр file_src ?<br />
пример не соответствует реально работающей форме</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 

Served from: tigor.com.ua @ 2025-08-12 18:38:57 by W3 Total Cache
-->