0

「タブ」を使用してモジュールを作成しました。各タブは次のようにコンポーネントを呼び出します。

include_component('logotipo', 'index');

コンポーネントのコードは次のとおりです。

class logotipoComponents extends sfComponents {

    public function executeIndex(sfWebRequest $request) {
        $id_empresa = $this->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();
        $this->sdriving_logotipo = Doctrine_Core::getTable('SdrivingLogotipo')->createQuery('a')->leftJoin('a.SdrivingEmpresa e')->where('e.idempresa = ?', $id_empresa)->execute();
    }

}

そして、これはテンプレート_index.phpです:

<?php if ($sdriving_logotipo->count() > 0): ?>
    <div class="span3">
        <span class="gris">Vista previa</span>
        <?php echo image_tag('/uploads/' . $sdriving_logotipo[0]->getArchivo()); ?>
    </div>
<?php else: ?>
    <div class="alert alert-block">
        <h4><?php echo __('Información!') ?></h4>
        <?php echo __('No se ha subido ningún logotipo aún. Haga clic en el botón "Subir nuevo" para crear uno.') ?>
    </div>
<?php endif; ?>

このコードは正常に動作しますが、もう少し必要です。ここで行う必要があるのは、logotipo を更新して新しいものをアップロードし、ファイル システムとデータベースから既存のものを削除するか、既存のレコードを編集して値を更新することです。これを見てみましょうschema.yml

SdrivingEmpresa:
  columns:
    idempresa:
      type: integer(4)
      unsigned: true
      primary: true
      autoincrement: true
    idlogotipo:
      type: integer(4)
      unsigned: true
      primary: true
    nombre_empresa:
      type: string(250)
      notnull: true
    ruta_emp:
      type: string(45)
      notnull: true
      autoincrement: false
  relations:
    SdrivingLogotipo:
      local: idlogotipo
      foreign: idlogotipo
      type: one
    SdrivingEmisor:
      local: idempresa
      foreign: idempresa
      type: many
    SdrivingMaquina:
      local: idempresa
      foreign: idempresa
      type: many
    SdrivingOperador:
      local: idempresa
      foreign: idempresa
      type: many
    SdrivingTurno:
      local: idempresa
      foreign: idempresa
      type: many
    SfGuardUserProfile:
      local: idempresa
      foreign: idempresa
      type: many

SdrivingLogotipo:
  columns:
    idlogotipo:
      type: integer(4)
      unsigned: true
      primary: true
      autoincrement: true
    archivo:
      type: string(250)
  relations:
    SdrivingEmpresa:
      local: idlogotipo
      foreign: idlogotipo
      type: many

最初のオプションを選択した場合、DB からファイル名を取得するためのクエリを作成し、ファイル システムからファイルを削除し、新しいファイルをアップロードして、SdrivingEmpresaアップロードされたファイルの新しい ID でテーブルを更新する必要があります。この場合、ID を取得する方法と、これらのアクションのロジックをどこに書き込むかがわかりませんprotected function processForm(sfWebRequest $request, sfForm $form) { }。'doSave($con = null){ }' でSdrivingLogotipoForm.class.php? どこ?

何か助けはありますか?

4

1 に答える 1

1

ajax を使用することをお勧めします。ajax というモジュールを作成し、そこでアクションとテンプレートのロジックを開発します。

各タブをクリックして ajax フォーム アクションを実行すると。

私のお勧めです。

幸運を。

于 2013-07-05T23:35:49.687 に答える