小编pea*_*ove的帖子

如何显示textarea的值?

我的textarea有一个值,但它没有显示在textarea中,它在我的输入字段中工作...

<textarea value="This text is not visible"></textarea>

<input value="This text is visible">
Run Code Online (Sandbox Code Playgroud)

html textarea

0
推荐指数
1
解决办法
1万
查看次数

如何启用/禁用另一个复选框旁边的复选框?

如果我选中左边的复选框之一,我希望它旁边的复选框将被启用。如果我取消选中左侧复选框之一,则应再次禁用它旁边的复选框:

$('input[type="checkbox"]').change(function () {
   $("input:checkbox:checked:not(.delivery)").each(function () {
      if ($("input:checkbox:checked").length > 0) {
        $(this).closest("tr").children('.disable').removeAttr("disabled");
      } else {
         $(this).closest("tr").children('.disable').addAttr("disabled");
      }
   });
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
   <td><input  type="checkbox"></td>
   <td><input class="disable" disabled="" type="checkbox"></td>
</tr>
<br>
<tr>
  <td><input  type="checkbox"></td>
  <td><input class="disable" disabled="" type="checkbox"></td>
</tr>
Run Code Online (Sandbox Code Playgroud)

使用我的代码,它保持禁用状态。

checkbox jquery

0
推荐指数
1
解决办法
1413
查看次数

如何从click事件中排除子类?

我想noclick从click函数中排除该类:

$( ".click" ).on( "click", ":not(.noclick *)", function() {
  console.log( $( this ).text() );
});
Run Code Online (Sandbox Code Playgroud)
.noclick{
background-color:pink;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table style="width:100%">
  <tr class="click">
    <th>Click</th>
    <th>Click</th>
    <th class="noclick">Nothing should happen here</th>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

jquery children

0
推荐指数
1
解决办法
63
查看次数

如何从数组中的字符串中删除最后一个空格?

我正在从一个文件创建一个数组:

$handle = fopen("inputfile.txt", "r");
if ($handle) {
    while (($str = fgets($handle)) !== false) {
           if (strlen($str) && $str[0] == '#') {
                    $pdate = substr($str, 1);
                    $date = rtrim($pdate);
                    $formatted = DateTime::createFromFormat('* M d H:i:s T Y',$date);
                }
                rtrim ($str, "\n");
                $exp = explode ('=', $str);
                if(count($exp) == 2){
                    $exp2 = explode('.', $exp[0]);  
                    if( count($exp2) == 2 ) {
                        if($exp2[1] == "dateTime"){
                            $s = str_replace("\\","",$exp[1]);
                            $d = strtotime($s);
                            $dateTime = date('Y-m-d H:i:s', $d);
                            $properties [$exp2[0]][$exp2[1]] = $dateTime;
                        } else { …
Run Code Online (Sandbox Code Playgroud)

php arrays string character-trimming

0
推荐指数
1
解决办法
69
查看次数

如何在Symfony 4中找到我的GET /用户路由

我收到一条错误消息,没有找到"GET/users"的路由:

级别:错误,频道:请求,消息:未捕获的PHP异常Symfony\Component\HttpKernel\Exception\NotFoundHttpException:"在/ Users/work/project/vendor/symfony/http-kernel /"找不到"GET/users"的路由EventListener/RouterListener.php第139行

但实际上我为"用户"设置了一条路线,所以我不知道如何解决这个问题:

<?php

namespace App\Controller;

use DataTables\DataTablesInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;

/**
*
* @Route("/users", name="users")
*
* @param Request $request
* @param DataTablesInterface $datatables
* @return JsonResponse
*/

class DataTableController extends Controller
{

  const ID = 'users';

  public function usersAction(Request $request, DataTablesInterface $datatables): JsonResponse
  {
    try {
      // Tell the DataTables service to process the request,
      // specifying ID of the required handler.
      $results = $datatables->handle($request, 'users');

      return $this->json($results);
    }
    catch (HttpException $e) { …
Run Code Online (Sandbox Code Playgroud)

php routing symfony

0
推荐指数
1
解决办法
161
查看次数

如何在生产模式下运行Symfony 4?

我正在使用Symfony探查器。但是我实际上只想使其在开发模式下可见。但是,当我通过git在服务器上推送数据并打开网站时,我看到了探查器。那没有道理,但我不知道如何消除。

我一直在寻找名为的文件config/config_dev.yml,config/config.yml因为我认为config/config.yml应该将其设置为:

web_profiler:
    toolbar: false
    intercept_redirects: false
Run Code Online (Sandbox Code Playgroud)

但是我没有任何config.yml文件。我必须创建它们吗?

profiler configuration symfony

0
推荐指数
1
解决办法
920
查看次数

如何在Symfony 4函数中替换变量?

我在Controller中创建了一个与Entity一起使用的函数Members.我现在要做的是使功能灵活,这样我就可以将它用于我所有其他实体.因此,实体的名称应该取决于slug.所以在这种情况下slug = members:

/**
  * @Route("/pages/{slug}/forms", name="forms", methods={"POST", "GET"})
  */

  public function form($slug, Request $request){
     $item = new Members();    
     $item= $this->getDoctrine()->getRepository(Members::class)->find($id);
 }
Run Code Online (Sandbox Code Playgroud)

所以我要做的是用slug替换实体名称:

/**
  * @Route("/pages/{slug}/forms", name="forms", methods={"POST", "GET"})
  */

  public function form($slug, Request $request){
     $item = new $slug();    
     $item= $this->getDoctrine()->getRepository($slug::class)->find($id);
 }
Run Code Online (Sandbox Code Playgroud)

但是我收到一条错误消息:

尝试从全局命名空间加载类"成员".你忘记了"使用"声明吗?

这是否与slug的大写/小写有关?

php variables controller function symfony

0
推荐指数
1
解决办法
54
查看次数

如何使用jquery从我的选择框中删除disabled属性?

我有一个简单的选择框:

   <select class="select">
                <option data-number="0" disabled>0</option>     
                <option data-number="1" disabled>1</option> 
                <option data-number="1" disabled>2</option>     
    </select>
Run Code Online (Sandbox Code Playgroud)

如果data-number为0,disabled则应删除该属性.我这样做的方式不起作用:

$(#'input').change(function () {
    if ($('.select').data('number') == 0) {
                alert("Hello! This working!!");
                $(this).data('number').prop('disabled', false);
    }
});
Run Code Online (Sandbox Code Playgroud)

当我选择时,我没有收到警报0(注意:我当然无法手动选择禁用选项,但系统会在输入更改时自动选择它)

jquery

-1
推荐指数
2
解决办法
1265
查看次数

如何在Symfony中减少使用扩展类型?

在我的控制器中,我使用了很多扩展类型:

use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
Run Code Online (Sandbox Code Playgroud)

因为这需要很多空间并且对我来说不清楚,我需要知道是否有一行只使用所有行.像这样的东西:

use Symfony\Component\Form\Extension\Core\Type\AllTypes;
Run Code Online (Sandbox Code Playgroud)

forms controller symfony

-1
推荐指数
1
解决办法
49
查看次数

如何从我的 ArrayCollection 获取数据?

我正在尝试通过学说从我的数组集合中加载数据:

 $pages = $this->em->getRepository(Pages::class)->findAll();
Run Code Online (Sandbox Code Playgroud)

结果是:

2 => Pages^ {#1598 ?
-id: 3
-name: "cat"
-membergroup: PersistentCollection^ {#1603 ?
  -snapshot: []
  -owner: Pages^ {#1598}
  -association: array:16 [ …16]
  -em: EntityManager^ {#278 …11}
  -backRefFieldName: "pages"
  -typeClass: ClassMetadata {#693 …}
  -isDirty: false
  #collection: ArrayCollection^ {#1604 ?
    -elements: []
  }
  #initialized: false
}
Run Code Online (Sandbox Code Playgroud)

}

问题是,我希望成员组 ArrayCollection 中有一个元素。但它是空的。

php doctrine arraycollection symfony

-1
推荐指数
1
解决办法
53
查看次数

如何判断我的数组中是否有某个数字?

我想知道我的数组中是否有数字:

array(1) { [0]=> string(5) "3,4,5" } 

 if (in_array('3', $array)) {
      echo 'in array';
 } else {
     echo 'not in array';
 }
Run Code Online (Sandbox Code Playgroud)

结果是,not in array但我期待in array

php arrays

-2
推荐指数
2
解决办法
89
查看次数