Yii2单击链接后基本插入表格

时间:2018-02-27 04:18:26

标签: php yii2 yii2-basic-app

我试图创建一个链接,以便使用视图和控制器

在表格上插入数据

查看我的代码

<!DOCTYPE html>
<html>
  <head>
    <title>Image Editor2</title>
  </head>
  <body>
    <!-- Load widget code -->
    <script type="text/javascript" src="http://feather.aviary.com/js/feather.js"></script>
    <!-- Instantiate the widget -->
    <script type="text/javascript">

      var featherEditor = new Aviary.Feather({
        apiKey: '1234567',
        apiVersion: 3,
        tools: ['draw', 'stickers'],
        onSave: function(imageID, newURL) {
          var img = document.getElementById(imageID);
          img.src = newURL;
        }
      });

      function launchEditor(id, src) {
        featherEditor.launch({
          image: id,
          url: src
        });
        return false;
      }
    </script>                         

    <!-- Add an edit button, passing the HTML id of the image
    and the public URL to the image -->
    <a href="#" onclick="return launchEditor('editableimage1','/goat.jpg');">Edit!</a>
    <!-- original line of HTML here: -->
    <img id="editableimage1" src="http://example.com/public/images/goat.jpg"/>
  </body>
</html>

但我不知道如何刷新页面并将数据插入表

我的数据是

<?= Html::a('Insert', ['view'], ['value' => 'insertdata' 'class' => 'btn btn-primary']) ?>

2 个答案:

答案 0 :(得分:0)

你可以这样做:

<?= Html::a('Insert', ['view', 'id' => $model->id], [
    'class' => 'btn btn-primary',
    'data'  => [
        'method' => 'POST',
        'params' => [
            'submit' => 'insertdata',
        ],
    ],
]) ?>

注意:我添加了额外的'id' => $model->id参数,您需要根据视图操作传递该参数。

答案 1 :(得分:0)

问题是你正在检查 1. Job-1 , Use envInject variable to define variables 2. Job -1 ,Updated the environment variables dynamically in groovy. Ex. env.version = '1.2' 3. Access the added environment variables from Job-2. 4. Its not giving the correct updated value, Environment variables always have the initial value configured in the Jobs configuration page.

对于帖子,好像你也会尝试手动设置锚点if (Yii::$app->request->post('submit') == 'insertdata') {属性中的data-param名称submit,它将不允许你点击链接而不会做任何事情,您必须将您在操作中检查的变量的名称更改为data或其他任何内容,因为Submit中的知道BUG将在 {{中修复1}}

yii.js

然后你可以建立如下链接

V 2.0.15