Symfony2嵌入了一系列表单(Symfony2 Embed a Collection of Forms)

嗨,我有形式嵌入的问题。 我有3个关系OneToMany的课程

StockTaking OneToMany StockTakingDetail ManyToOne Hardware

我提交表格时,我收到错误。 我不知道我犯了什么错误。

错误:

可捕获的致命错误:传递给AppBundle \ Entity \ MagazineStockTakingDetails :: setHardware()的参数1必须是AppBundle \ Entity \ Hardware的实例,给定的数组,在C:\ Projekty \ sla \ vendor \ symfony \ symfony \ src \ Symfony中调用第442行上的\ Component \ PropertyAccess \ PropertyAccessor.php并定义

我在下面编写了我的课程和表格。 请帮我找错。

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;


/**
 * Class MagazineStockTaking
 * @package AppBundle\Entity
 * @ORM\Entity()
 * @ORM\Table(name="sla_stocktaking")
 */
class MagazineStockTaking
{

    /**
     * @ORM\Id
     * @ORM\Column(name="stockTakingId", type="integer", nullable=false)
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="stockinNumber", type="string", length=20, nullable=false)
     */
    protected $stockingnumber;

    /**
     * @ORM\Column(name="stockinDate", type="datetime", nullable=false)
     */
    protected $stockingdate;

    /**
     * @ORM\Column(name="stockingNote", type="string", length=1000, nullable=false)
     */
    protected $stockingnote;

    ////////////////////////////////////////////////
    // RELACJE
    ////////////////////////////////////////////////


    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Magazine", inversedBy="stocktaking")
     * @ORM\JoinColumn(name="magazine_id", referencedColumnName="magazineId", nullable=false)
     */
    protected $magazine;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="stocktaking")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="userId", nullable=false)
     */
    protected $user;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineStockTakingDetails", mappedBy="stocktaking", cascade={"persist"})
     */
    protected $details;

    ////////////////////////////////////////////////
    // GET SET
    ////////////////////////////////////////////////

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->details = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set stockingnumber
     *
     * @param string $stockingnumber
     * @return MagazineStockTaking
     */
    public function setStockingnumber($stockingnumber)
    {
        $this->stockingnumber = $stockingnumber;

        return $this;
    }

    /**
     * Get stockingnumber
     *
     * @return string
     */
    public function getStockingnumber()
    {
        return $this->stockingnumber;
    }

    /**
     * Set stockingdate
     *
     * @param \DateTime $stockingdate
     * @return MagazineStockTaking
     */
    public function setStockingdate($stockingdate)
    {
        $this->stockingdate = $stockingdate;

        return $this;
    }

    /**
     * Get stockingdate
     *
     * @return \DateTime
     */
    public function getStockingdate()
    {
        return $this->stockingdate;
    }

    /**
     * Set stockingnote
     *
     * @param string $stockingnote
     * @return MagazineStockTaking
     */
    public function setStockingnote($stockingnote)
    {
        $this->stockingnote = $stockingnote;

        return $this;
    }

    /**
     * Get stockingnote
     *
     * @return string
     */
    public function getStockingnote()
    {
        return $this->stockingnote;
    }

    /**
     * Set magazine
     *
     * @param \AppBundle\Entity\Magazine $magazine
     * @return MagazineStockTaking
     */
    public function setMagazine(\AppBundle\Entity\Magazine $magazine)
    {
        $this->magazine = $magazine;

        return $this;
    }

    /**
     * Get magazine
     *
     * @return \AppBundle\Entity\Magazine
     */
    public function getMagazine()
    {
        return $this->magazine;
    }

    /**
     * Set user
     *
     * @param \AppBundle\Entity\User $user
     * @return MagazineStockTaking
     */
    public function setUser(\AppBundle\Entity\User $user)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \AppBundle\Entity\User
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Add details
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $details
     * @return MagazineStockTaking
     */
    public function addDetail(\AppBundle\Entity\MagazineStockTakingDetails $details)
    {
        $this->details[] = $details;

        return $this;
    }

    /**
     * Remove details
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $details
     */
    public function removeDetail(\AppBundle\Entity\MagazineStockTakingDetails $details)
    {
        $this->details->removeElement($details);
    }

    /**
     * Get details
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getDetails()
    {
        return $this->details;
    }
}

二等

<?php


namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class MagazineStockTakingDetails
 * @package AppBundle\Entity
 * @ORM\Entity()
 * @ORM\Table(name="sla_stocktakingdetails")
 */
class MagazineStockTakingDetails
{

    /**
     * @ORM\Id()
     * @ORM\Column(name="stackTakingDetailsId", type="integer", nullable=false)
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="hardwareCount", type="integer", nullable=false)
     */
    protected $count = 1;


    /////////////////////////////////////////////
    // RELACJE
    /////////////////////////////////////////////

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\MagazineStockTaking", inversedBy="details")
     * @ORM\JoinColumn(name="stacktaking_id", referencedColumnName="stockTakingId", nullable=false)
     */
    protected $stocktaking;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Hardware", inversedBy="stocktakingdetails",cascade={"persist"})
     * @ORM\JoinColumn(name="hardware_id", referencedColumnName="hardwareId", nullable=false)
     */
    protected $hardware;

    /////////////////////////////////////////////
    // GET SET
    /////////////////////////////////////////////



    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set count
     *
     * @param integer $count
     * @return MagazineStockTakingDetails
     */
    public function setCount($count)
    {
        $this->count = $count;

        return $this;
    }

    /**
     * Get count
     *
     * @return integer 
     */
    public function getCount()
    {
        return $this->count;
    }

    /**
     * Set stocktaking
     *
     * @param \AppBundle\Entity\MagazineStockTaking $stocktaking
     * @return MagazineStockTakingDetails
     */
    public function setStocktaking(\AppBundle\Entity\MagazineStockTaking $stocktaking)
    {
        $this->stocktaking = $stocktaking;

        return $this;
    }

    /**
     * Get stocktaking
     *
     * @return \AppBundle\Entity\MagazineStockTaking 
     */
    public function getStocktaking()
    {
        return $this->stocktaking;
    }


    /**
     * Set hardware
     *
     * @param \AppBundle\Entity\Hardware $hardware
     * @return MagazineStockTakingDetails
     */
    public function setHardware(\AppBundle\Entity\Hardware $hardware)
    {

        $this->hardware = $hardware;

        return $this;
    }

    /**
     * Get hardware
     *
     * @return \AppBundle\Entity\Hardware 
     */
    public function getHardware()
    {
        return $this->hardware;
    }
}

三等

<?php


namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use JMS\Serializer\Annotation\Groups;


/**
 * Class Hardware
 * @package AppBundle\Entity
 * @ORM\Entity(repositoryClass="HardwareRepository", )
 * @ORM\Table(name="sla_hardwares")
 * @JMS\ExclusionPolicy("all")
 */
class Hardware
{

    /**
     * @ORM\Id()
     * @ORM\Column(name="hardwareId", type="integer", nullable=false)
     * @ORM\GeneratedValue(strategy="AUTO")
    */
    protected $id;

    /**
     * @ORM\Column(name="hardwareSn", type="string", length=200, nullable=true)
     */
    protected $sn;

    /**
     * @ORM\Column(name="hardwareGwarantyDate", type="datetime", nullable=true)
     */
    protected $gwarantydate;

    /**
     * @ORM\Column(name="hardwareNote", type="string", length=750, nullable=true)
     */
    protected $note;

    /**
     * @ORM\Column(name="hardwareIsReturned", type="boolean", nullable=false)
     */
    protected $isreturned = false;

    ////////////////////////////////////////
    //// RELACJE
    ////////////////////////////////////////

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareProducent", inversedBy="hardware")
     * @ORM\JoinColumn(name="producent_id", referencedColumnName="producentId", nullable=false)
    */
    protected $producent;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareCategory", inversedBy="hardware")
     * @ORM\JoinColumn(name="category_id", referencedColumnName="hardwareCategoryId", nullable=false)
     */
    protected $category;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareModel", inversedBy="hardware")
     * @ORM\JoinColumn(name="model_id", referencedColumnName="hardwareModelId", nullable=false)
     */
    protected $model;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareStatus", inversedBy="hardware")
     * @ORM\JoinColumn(name="status_id", referencedColumnName="statusId", nullable=false)
     */
    protected $status;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\HardwareStatusHistory", mappedBy="hardware")
     */
    protected $statushistory;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineDetails", mappedBy="hardware")
     */
    protected $magazine;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineShiftDetails", mappedBy="hardware")
     */
    protected $magazineshift;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineUtilizeDetails", mappedBy="hardware")
     */
    protected $utilize;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineStockTakingDetails", mappedBy="hardware", cascade={"persist"})
     */
    protected $stocktakingdetails;

    ////////////////////////////////////////
    //// GET SET
    ////////////////////////////////////////
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->statushistory = new \Doctrine\Common\Collections\ArrayCollection();
        $this->magazine = new \Doctrine\Common\Collections\ArrayCollection();
        $this->magazineshift = new \Doctrine\Common\Collections\ArrayCollection();
        $this->utilize = new \Doctrine\Common\Collections\ArrayCollection();
        $this->stocktakingdetails = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set sn
     *
     * @param string $sn
     * @return Hardware
     */
    public function setSn($sn)
    {
        $this->sn = $sn;

        return $this;
    }

    /**
     * Get sn
     *
     * @return string 
     */
    public function getSn()
    {
        return $this->sn;
    }

    /**
     * Set gwarantydate
     *
     * @param \DateTime $gwarantydate
     * @return Hardware
     */
    public function setGwarantydate($gwarantydate)
    {
        $this->gwarantydate = $gwarantydate;

        return $this;
    }

    /**
     * Get gwarantydate
     *
     * @return \DateTime 
     */
    public function getGwarantydate()
    {
        return $this->gwarantydate;
    }

    /**
     * Set note
     *
     * @param string $note
     * @return Hardware
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

    /**
     * Get note
     *
     * @return string 
     */
    public function getNote()
    {
        return $this->note;
    }

    /**
     * Set isreturned
     *
     * @param boolean $isreturned
     * @return Hardware
     */
    public function setIsreturned($isreturned)
    {
        $this->isreturned = $isreturned;

        return $this;
    }

    /**
     * Get isreturned
     *
     * @return boolean 
     */
    public function getIsreturned()
    {
        return $this->isreturned;
    }

    /**
     * Set producent
     *
     * @param \AppBundle\Entity\HardwareProducent $producent
     * @return Hardware
     */
    public function setProducent(\AppBundle\Entity\HardwareProducent $producent)
    {
        $this->producent = $producent;

        return $this;
    }

    /**
     * Get producent
     *
     * @return \AppBundle\Entity\HardwareProducent 
     */
    public function getProducent()
    {
        return $this->producent;
    }

    /**
     * Set category
     *
     * @param \AppBundle\Entity\HardwareCategory $category
     * @return Hardware
     */
    public function setCategory(\AppBundle\Entity\HardwareCategory $category)
    {
        $this->category = $category;

        return $this;
    }

    /**
     * Get category
     *
     * @return \AppBundle\Entity\HardwareCategory 
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * Set model
     *
     * @param \AppBundle\Entity\HardwareModel $model
     * @return Hardware
     */
    public function setModel(\AppBundle\Entity\HardwareModel $model)
    {
        $this->model = $model;

        return $this;
    }

    /**
     * Get model
     *
     * @return \AppBundle\Entity\HardwareModel 
     */
    public function getModel()
    {
        return $this->model;
    }

    /**
     * Set status
     *
     * @param \AppBundle\Entity\HardwareStatus $status
     * @return Hardware
     */
    public function setStatus(\AppBundle\Entity\HardwareStatus $status)
    {
        $this->status = $status;

        return $this;
    }

    /**
     * Get status
     *
     * @return \AppBundle\Entity\HardwareStatus 
     */
    public function getStatus()
    {
        return $this->status;
    }

    /**
     * Add statushistory
     *
     * @param \AppBundle\Entity\HardwareStatusHistory $statushistory
     * @return Hardware
     */
    public function addStatushistory(\AppBundle\Entity\HardwareStatusHistory $statushistory)
    {
        $this->statushistory[] = $statushistory;

        return $this;
    }

    /**
     * Remove statushistory
     *
     * @param \AppBundle\Entity\HardwareStatusHistory $statushistory
     */
    public function removeStatushistory(\AppBundle\Entity\HardwareStatusHistory $statushistory)
    {
        $this->statushistory->removeElement($statushistory);
    }

    /**
     * Get statushistory
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getStatushistory()
    {
        return $this->statushistory;
    }

    /**
     * Add magazine
     *
     * @param \AppBundle\Entity\MagazineDetails $magazine
     * @return Hardware
     */
    public function addMagazine(\AppBundle\Entity\MagazineDetails $magazine)
    {
        $this->magazine[] = $magazine;

        return $this;
    }

    /**
     * Remove magazine
     *
     * @param \AppBundle\Entity\MagazineDetails $magazine
     */
    public function removeMagazine(\AppBundle\Entity\MagazineDetails $magazine)
    {
        $this->magazine->removeElement($magazine);
    }

    /**
     * Get magazine
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getMagazine()
    {
        return $this->magazine;
    }

    /**
     * Add magazineshift
     *
     * @param \AppBundle\Entity\MagazineShiftDetails $magazineshift
     * @return Hardware
     */
    public function addMagazineshift(\AppBundle\Entity\MagazineShiftDetails $magazineshift)
    {
        $this->magazineshift[] = $magazineshift;

        return $this;
    }

    /**
     * Remove magazineshift
     *
     * @param \AppBundle\Entity\MagazineShiftDetails $magazineshift
     */
    public function removeMagazineshift(\AppBundle\Entity\MagazineShiftDetails $magazineshift)
    {
        $this->magazineshift->removeElement($magazineshift);
    }

    /**
     * Get magazineshift
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getMagazineshift()
    {
        return $this->magazineshift;
    }

    /**
     * Add utilize
     *
     * @param \AppBundle\Entity\MagazineUtilizeDetails $utilize
     * @return Hardware
     */
    public function addUtilize(\AppBundle\Entity\MagazineUtilizeDetails $utilize)
    {
        $this->utilize[] = $utilize;

        return $this;
    }

    /**
     * Remove utilize
     *
     * @param \AppBundle\Entity\MagazineUtilizeDetails $utilize
     */
    public function removeUtilize(\AppBundle\Entity\MagazineUtilizeDetails $utilize)
    {
        $this->utilize->removeElement($utilize);
    }

    /**
     * Get utilize
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getUtilize()
    {
        return $this->utilize;
    }

    /**
     * Add stocktakingdetails
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails
     * @return Hardware
     */
    public function addStocktakingdetail(\AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails)
    {
        $this->stocktakingdetails[] = $stocktakingdetails;
        $stocktakingdetails->setHardware($this);

        return $this;
    }

    /**
     * Remove stocktakingdetails
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails
     */
    public function removeStocktakingdetail(\AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails)
    {
        $this->stocktakingdetails->removeElement($stocktakingdetails);
    }

    /**
     * Get stocktakingdetails
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getStocktakingdetails()
    {
        return $this->stocktakingdetails;
    }
}

第一表格类

<?php


namespace AppBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class StockTakingFormType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('stockingnote','textarea',array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-textarea',
                    'placeholder' => 'Uwagi',
                    'data-text' => 'Uwagi'
                ),
                'required' => false
            ))
            ->add('details','collection',array(
                'type' => new StockTakingDetailFormType(),
                'allow_add' => true,
                'by_reference' => false
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\MagazineStockTaking',
            'attr' => array(
                'id' => 'form_stoking'
            )
        ));
    }

    public function getName() {
        return 'stocktaking';
    }

}

第二表格类

<?php

namespace AppBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class StockTakingDetailFormType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $builder
            ->add('count','number',array(
                'label' => false,
                'data' => '1',
                'required' => false
            ))
            ->add('hardware','collection',array(
                'type' => new HardwareFormType(),
                'allow_add' => true,
                'by_reference' => false
            ))
        ;

    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
           'data_class' => 'AppBundle\Entity\MagazineStockTakingDetails'
        ));
    }

    public function getName()
    {
        return 'stocktakingtetail';
    }

}

第三表格类

namespace AppBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class HardwareFormType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('sn','text',array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-input',
                    'placeholder' => 'Numer Seryjny Urządzenia'
                ),
                'required' => true
            ))
            ->add('gwarantydate','number',array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-input',
                    'placeholder' => 'Ilość Gwarancji (miesięcy)'
                ),
                'required' => false
            ))
            ->add('isreturned','checkbox',array(
                'label' => 'Sprzęt Rotacyjny',
                'label_attr' => array(
                    'class' => 'option-primary'
                ),
                'required' => true
            ))
            ->add('note','textarea' ,array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-textarea',
                    'placeholder' => 'Opis',
                    'data-text' => 'Opis'
                ),
                'required' => false
            ))
            ->add('producent','entity',array(
                'class' => 'AppBundle\Entity\HardwareProducent',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Producent'
                ),
                'required' => true
            ))
            ->add('category','entity',array(
                'class' => 'AppBundle\Entity\HardwareCategory',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Kategoria'
                ),
                'required' => true
            ))
            ->add('model','entity',array(
                'class' => 'AppBundle\Entity\HardwareModel',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Model'
                ),
                'required' => true
            ))
            ->add('status','entity',array(
                'class' => 'AppBundle\Entity\HardwareStatus',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Status'
                ),
                'required' => true
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\Hardware'
        ));
    }

    public function getName()
    {
        return 'hardware';
    }

}

Hi i have problem with form embeded. I have 3 class with relation OneToMany

StockTaking OneToMany StockTakingDetail ManyToOne Hardware

Wheh i submit the form i get error. I dont know where I made a mistake.

Error:

Catchable Fatal Error: Argument 1 passed to AppBundle\Entity\MagazineStockTakingDetails::setHardware() must be an instance of AppBundle\Entity\Hardware, array given, called in C:\Projekty\sla\vendor\symfony\symfony\src\Symfony\Component\PropertyAccess\PropertyAccessor.php on line 442 and defined

Below i past code my class and form. Please help me find mistake.

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;


/**
 * Class MagazineStockTaking
 * @package AppBundle\Entity
 * @ORM\Entity()
 * @ORM\Table(name="sla_stocktaking")
 */
class MagazineStockTaking
{

    /**
     * @ORM\Id
     * @ORM\Column(name="stockTakingId", type="integer", nullable=false)
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="stockinNumber", type="string", length=20, nullable=false)
     */
    protected $stockingnumber;

    /**
     * @ORM\Column(name="stockinDate", type="datetime", nullable=false)
     */
    protected $stockingdate;

    /**
     * @ORM\Column(name="stockingNote", type="string", length=1000, nullable=false)
     */
    protected $stockingnote;

    ////////////////////////////////////////////////
    // RELACJE
    ////////////////////////////////////////////////


    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Magazine", inversedBy="stocktaking")
     * @ORM\JoinColumn(name="magazine_id", referencedColumnName="magazineId", nullable=false)
     */
    protected $magazine;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="stocktaking")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="userId", nullable=false)
     */
    protected $user;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineStockTakingDetails", mappedBy="stocktaking", cascade={"persist"})
     */
    protected $details;

    ////////////////////////////////////////////////
    // GET SET
    ////////////////////////////////////////////////

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->details = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set stockingnumber
     *
     * @param string $stockingnumber
     * @return MagazineStockTaking
     */
    public function setStockingnumber($stockingnumber)
    {
        $this->stockingnumber = $stockingnumber;

        return $this;
    }

    /**
     * Get stockingnumber
     *
     * @return string
     */
    public function getStockingnumber()
    {
        return $this->stockingnumber;
    }

    /**
     * Set stockingdate
     *
     * @param \DateTime $stockingdate
     * @return MagazineStockTaking
     */
    public function setStockingdate($stockingdate)
    {
        $this->stockingdate = $stockingdate;

        return $this;
    }

    /**
     * Get stockingdate
     *
     * @return \DateTime
     */
    public function getStockingdate()
    {
        return $this->stockingdate;
    }

    /**
     * Set stockingnote
     *
     * @param string $stockingnote
     * @return MagazineStockTaking
     */
    public function setStockingnote($stockingnote)
    {
        $this->stockingnote = $stockingnote;

        return $this;
    }

    /**
     * Get stockingnote
     *
     * @return string
     */
    public function getStockingnote()
    {
        return $this->stockingnote;
    }

    /**
     * Set magazine
     *
     * @param \AppBundle\Entity\Magazine $magazine
     * @return MagazineStockTaking
     */
    public function setMagazine(\AppBundle\Entity\Magazine $magazine)
    {
        $this->magazine = $magazine;

        return $this;
    }

    /**
     * Get magazine
     *
     * @return \AppBundle\Entity\Magazine
     */
    public function getMagazine()
    {
        return $this->magazine;
    }

    /**
     * Set user
     *
     * @param \AppBundle\Entity\User $user
     * @return MagazineStockTaking
     */
    public function setUser(\AppBundle\Entity\User $user)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \AppBundle\Entity\User
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Add details
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $details
     * @return MagazineStockTaking
     */
    public function addDetail(\AppBundle\Entity\MagazineStockTakingDetails $details)
    {
        $this->details[] = $details;

        return $this;
    }

    /**
     * Remove details
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $details
     */
    public function removeDetail(\AppBundle\Entity\MagazineStockTakingDetails $details)
    {
        $this->details->removeElement($details);
    }

    /**
     * Get details
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getDetails()
    {
        return $this->details;
    }
}

Second Class

<?php


namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class MagazineStockTakingDetails
 * @package AppBundle\Entity
 * @ORM\Entity()
 * @ORM\Table(name="sla_stocktakingdetails")
 */
class MagazineStockTakingDetails
{

    /**
     * @ORM\Id()
     * @ORM\Column(name="stackTakingDetailsId", type="integer", nullable=false)
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="hardwareCount", type="integer", nullable=false)
     */
    protected $count = 1;


    /////////////////////////////////////////////
    // RELACJE
    /////////////////////////////////////////////

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\MagazineStockTaking", inversedBy="details")
     * @ORM\JoinColumn(name="stacktaking_id", referencedColumnName="stockTakingId", nullable=false)
     */
    protected $stocktaking;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Hardware", inversedBy="stocktakingdetails",cascade={"persist"})
     * @ORM\JoinColumn(name="hardware_id", referencedColumnName="hardwareId", nullable=false)
     */
    protected $hardware;

    /////////////////////////////////////////////
    // GET SET
    /////////////////////////////////////////////



    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set count
     *
     * @param integer $count
     * @return MagazineStockTakingDetails
     */
    public function setCount($count)
    {
        $this->count = $count;

        return $this;
    }

    /**
     * Get count
     *
     * @return integer 
     */
    public function getCount()
    {
        return $this->count;
    }

    /**
     * Set stocktaking
     *
     * @param \AppBundle\Entity\MagazineStockTaking $stocktaking
     * @return MagazineStockTakingDetails
     */
    public function setStocktaking(\AppBundle\Entity\MagazineStockTaking $stocktaking)
    {
        $this->stocktaking = $stocktaking;

        return $this;
    }

    /**
     * Get stocktaking
     *
     * @return \AppBundle\Entity\MagazineStockTaking 
     */
    public function getStocktaking()
    {
        return $this->stocktaking;
    }


    /**
     * Set hardware
     *
     * @param \AppBundle\Entity\Hardware $hardware
     * @return MagazineStockTakingDetails
     */
    public function setHardware(\AppBundle\Entity\Hardware $hardware)
    {

        $this->hardware = $hardware;

        return $this;
    }

    /**
     * Get hardware
     *
     * @return \AppBundle\Entity\Hardware 
     */
    public function getHardware()
    {
        return $this->hardware;
    }
}

Third Class

<?php


namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use JMS\Serializer\Annotation\Groups;


/**
 * Class Hardware
 * @package AppBundle\Entity
 * @ORM\Entity(repositoryClass="HardwareRepository", )
 * @ORM\Table(name="sla_hardwares")
 * @JMS\ExclusionPolicy("all")
 */
class Hardware
{

    /**
     * @ORM\Id()
     * @ORM\Column(name="hardwareId", type="integer", nullable=false)
     * @ORM\GeneratedValue(strategy="AUTO")
    */
    protected $id;

    /**
     * @ORM\Column(name="hardwareSn", type="string", length=200, nullable=true)
     */
    protected $sn;

    /**
     * @ORM\Column(name="hardwareGwarantyDate", type="datetime", nullable=true)
     */
    protected $gwarantydate;

    /**
     * @ORM\Column(name="hardwareNote", type="string", length=750, nullable=true)
     */
    protected $note;

    /**
     * @ORM\Column(name="hardwareIsReturned", type="boolean", nullable=false)
     */
    protected $isreturned = false;

    ////////////////////////////////////////
    //// RELACJE
    ////////////////////////////////////////

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareProducent", inversedBy="hardware")
     * @ORM\JoinColumn(name="producent_id", referencedColumnName="producentId", nullable=false)
    */
    protected $producent;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareCategory", inversedBy="hardware")
     * @ORM\JoinColumn(name="category_id", referencedColumnName="hardwareCategoryId", nullable=false)
     */
    protected $category;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareModel", inversedBy="hardware")
     * @ORM\JoinColumn(name="model_id", referencedColumnName="hardwareModelId", nullable=false)
     */
    protected $model;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HardwareStatus", inversedBy="hardware")
     * @ORM\JoinColumn(name="status_id", referencedColumnName="statusId", nullable=false)
     */
    protected $status;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\HardwareStatusHistory", mappedBy="hardware")
     */
    protected $statushistory;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineDetails", mappedBy="hardware")
     */
    protected $magazine;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineShiftDetails", mappedBy="hardware")
     */
    protected $magazineshift;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineUtilizeDetails", mappedBy="hardware")
     */
    protected $utilize;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\MagazineStockTakingDetails", mappedBy="hardware", cascade={"persist"})
     */
    protected $stocktakingdetails;

    ////////////////////////////////////////
    //// GET SET
    ////////////////////////////////////////
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->statushistory = new \Doctrine\Common\Collections\ArrayCollection();
        $this->magazine = new \Doctrine\Common\Collections\ArrayCollection();
        $this->magazineshift = new \Doctrine\Common\Collections\ArrayCollection();
        $this->utilize = new \Doctrine\Common\Collections\ArrayCollection();
        $this->stocktakingdetails = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set sn
     *
     * @param string $sn
     * @return Hardware
     */
    public function setSn($sn)
    {
        $this->sn = $sn;

        return $this;
    }

    /**
     * Get sn
     *
     * @return string 
     */
    public function getSn()
    {
        return $this->sn;
    }

    /**
     * Set gwarantydate
     *
     * @param \DateTime $gwarantydate
     * @return Hardware
     */
    public function setGwarantydate($gwarantydate)
    {
        $this->gwarantydate = $gwarantydate;

        return $this;
    }

    /**
     * Get gwarantydate
     *
     * @return \DateTime 
     */
    public function getGwarantydate()
    {
        return $this->gwarantydate;
    }

    /**
     * Set note
     *
     * @param string $note
     * @return Hardware
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

    /**
     * Get note
     *
     * @return string 
     */
    public function getNote()
    {
        return $this->note;
    }

    /**
     * Set isreturned
     *
     * @param boolean $isreturned
     * @return Hardware
     */
    public function setIsreturned($isreturned)
    {
        $this->isreturned = $isreturned;

        return $this;
    }

    /**
     * Get isreturned
     *
     * @return boolean 
     */
    public function getIsreturned()
    {
        return $this->isreturned;
    }

    /**
     * Set producent
     *
     * @param \AppBundle\Entity\HardwareProducent $producent
     * @return Hardware
     */
    public function setProducent(\AppBundle\Entity\HardwareProducent $producent)
    {
        $this->producent = $producent;

        return $this;
    }

    /**
     * Get producent
     *
     * @return \AppBundle\Entity\HardwareProducent 
     */
    public function getProducent()
    {
        return $this->producent;
    }

    /**
     * Set category
     *
     * @param \AppBundle\Entity\HardwareCategory $category
     * @return Hardware
     */
    public function setCategory(\AppBundle\Entity\HardwareCategory $category)
    {
        $this->category = $category;

        return $this;
    }

    /**
     * Get category
     *
     * @return \AppBundle\Entity\HardwareCategory 
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * Set model
     *
     * @param \AppBundle\Entity\HardwareModel $model
     * @return Hardware
     */
    public function setModel(\AppBundle\Entity\HardwareModel $model)
    {
        $this->model = $model;

        return $this;
    }

    /**
     * Get model
     *
     * @return \AppBundle\Entity\HardwareModel 
     */
    public function getModel()
    {
        return $this->model;
    }

    /**
     * Set status
     *
     * @param \AppBundle\Entity\HardwareStatus $status
     * @return Hardware
     */
    public function setStatus(\AppBundle\Entity\HardwareStatus $status)
    {
        $this->status = $status;

        return $this;
    }

    /**
     * Get status
     *
     * @return \AppBundle\Entity\HardwareStatus 
     */
    public function getStatus()
    {
        return $this->status;
    }

    /**
     * Add statushistory
     *
     * @param \AppBundle\Entity\HardwareStatusHistory $statushistory
     * @return Hardware
     */
    public function addStatushistory(\AppBundle\Entity\HardwareStatusHistory $statushistory)
    {
        $this->statushistory[] = $statushistory;

        return $this;
    }

    /**
     * Remove statushistory
     *
     * @param \AppBundle\Entity\HardwareStatusHistory $statushistory
     */
    public function removeStatushistory(\AppBundle\Entity\HardwareStatusHistory $statushistory)
    {
        $this->statushistory->removeElement($statushistory);
    }

    /**
     * Get statushistory
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getStatushistory()
    {
        return $this->statushistory;
    }

    /**
     * Add magazine
     *
     * @param \AppBundle\Entity\MagazineDetails $magazine
     * @return Hardware
     */
    public function addMagazine(\AppBundle\Entity\MagazineDetails $magazine)
    {
        $this->magazine[] = $magazine;

        return $this;
    }

    /**
     * Remove magazine
     *
     * @param \AppBundle\Entity\MagazineDetails $magazine
     */
    public function removeMagazine(\AppBundle\Entity\MagazineDetails $magazine)
    {
        $this->magazine->removeElement($magazine);
    }

    /**
     * Get magazine
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getMagazine()
    {
        return $this->magazine;
    }

    /**
     * Add magazineshift
     *
     * @param \AppBundle\Entity\MagazineShiftDetails $magazineshift
     * @return Hardware
     */
    public function addMagazineshift(\AppBundle\Entity\MagazineShiftDetails $magazineshift)
    {
        $this->magazineshift[] = $magazineshift;

        return $this;
    }

    /**
     * Remove magazineshift
     *
     * @param \AppBundle\Entity\MagazineShiftDetails $magazineshift
     */
    public function removeMagazineshift(\AppBundle\Entity\MagazineShiftDetails $magazineshift)
    {
        $this->magazineshift->removeElement($magazineshift);
    }

    /**
     * Get magazineshift
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getMagazineshift()
    {
        return $this->magazineshift;
    }

    /**
     * Add utilize
     *
     * @param \AppBundle\Entity\MagazineUtilizeDetails $utilize
     * @return Hardware
     */
    public function addUtilize(\AppBundle\Entity\MagazineUtilizeDetails $utilize)
    {
        $this->utilize[] = $utilize;

        return $this;
    }

    /**
     * Remove utilize
     *
     * @param \AppBundle\Entity\MagazineUtilizeDetails $utilize
     */
    public function removeUtilize(\AppBundle\Entity\MagazineUtilizeDetails $utilize)
    {
        $this->utilize->removeElement($utilize);
    }

    /**
     * Get utilize
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getUtilize()
    {
        return $this->utilize;
    }

    /**
     * Add stocktakingdetails
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails
     * @return Hardware
     */
    public function addStocktakingdetail(\AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails)
    {
        $this->stocktakingdetails[] = $stocktakingdetails;
        $stocktakingdetails->setHardware($this);

        return $this;
    }

    /**
     * Remove stocktakingdetails
     *
     * @param \AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails
     */
    public function removeStocktakingdetail(\AppBundle\Entity\MagazineStockTakingDetails $stocktakingdetails)
    {
        $this->stocktakingdetails->removeElement($stocktakingdetails);
    }

    /**
     * Get stocktakingdetails
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getStocktakingdetails()
    {
        return $this->stocktakingdetails;
    }
}

First Form Class

<?php


namespace AppBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class StockTakingFormType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('stockingnote','textarea',array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-textarea',
                    'placeholder' => 'Uwagi',
                    'data-text' => 'Uwagi'
                ),
                'required' => false
            ))
            ->add('details','collection',array(
                'type' => new StockTakingDetailFormType(),
                'allow_add' => true,
                'by_reference' => false
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\MagazineStockTaking',
            'attr' => array(
                'id' => 'form_stoking'
            )
        ));
    }

    public function getName() {
        return 'stocktaking';
    }

}

Second Form Class

<?php

namespace AppBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class StockTakingDetailFormType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $builder
            ->add('count','number',array(
                'label' => false,
                'data' => '1',
                'required' => false
            ))
            ->add('hardware','collection',array(
                'type' => new HardwareFormType(),
                'allow_add' => true,
                'by_reference' => false
            ))
        ;

    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
           'data_class' => 'AppBundle\Entity\MagazineStockTakingDetails'
        ));
    }

    public function getName()
    {
        return 'stocktakingtetail';
    }

}

Third Form Class

namespace AppBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class HardwareFormType extends AbstractType
{

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('sn','text',array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-input',
                    'placeholder' => 'Numer Seryjny Urządzenia'
                ),
                'required' => true
            ))
            ->add('gwarantydate','number',array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-input',
                    'placeholder' => 'Ilość Gwarancji (miesięcy)'
                ),
                'required' => false
            ))
            ->add('isreturned','checkbox',array(
                'label' => 'Sprzęt Rotacyjny',
                'label_attr' => array(
                    'class' => 'option-primary'
                ),
                'required' => true
            ))
            ->add('note','textarea' ,array(
                'label' => false,
                'attr' => array(
                    'class' => 'gui-textarea',
                    'placeholder' => 'Opis',
                    'data-text' => 'Opis'
                ),
                'required' => false
            ))
            ->add('producent','entity',array(
                'class' => 'AppBundle\Entity\HardwareProducent',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Producent'
                ),
                'required' => true
            ))
            ->add('category','entity',array(
                'class' => 'AppBundle\Entity\HardwareCategory',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Kategoria'
                ),
                'required' => true
            ))
            ->add('model','entity',array(
                'class' => 'AppBundle\Entity\HardwareModel',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Model'
                ),
                'required' => true
            ))
            ->add('status','entity',array(
                'class' => 'AppBundle\Entity\HardwareStatus',
                'property' => 'name',
                'label' => false,
                'attr' => array(
                    'class' => 'select',
                    'placeholder' => 'Status'
                ),
                'required' => true
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\Hardware'
        ));
    }

    public function getName()
    {
        return 'hardware';
    }

}

原文:https://stackoverflow.com/questions/34908781
2023-11-10 22:11

满意答案

你也可以添加一个对数函数。 (取自tagadelic,我的Drupal模块创建标签云http://drupal.org/project/tagadelic ):

db_query('SELECT COUNT(*) AS count, id, name FROM ... ORDER BY count DESC');

$steps = 6;
$tags = array();
$min = 1e9;
$max = -1e9;

while ($tag = db_fetch_object($result)) {
    $tag->number_of_posts = $tag->count; #sets the amount of items a certain tag has attached to it
    $tag->count = log($tag->count);
    $min = min($min, $tag->count);
    $max = max($max, $tag->count);
    $tags[$tag->tid] = $tag;
}
// Note: we need to ensure the range is slightly too large to make sure even
// the largest element is rounded down.
$range = max(.01, $max - $min) * 1.0001;

foreach ($tags as $key => $value) {
    $tags[$key]->weight = 1 + floor($steps * ($value->count - $min) / $range);
}

然后在您的视图或模板中:

foreach ($tags as $tag) {
    $output .= "<h$tag->weight>$tag->name</h$tag->weight>"
}

You will want to add a logarithmic function to it too. (taken from tagadelic, my Drupal module to create tag clouds http://drupal.org/project/tagadelic):

db_query('SELECT COUNT(*) AS count, id, name FROM ... ORDER BY count DESC');

$steps = 6;
$tags = array();
$min = 1e9;
$max = -1e9;

while ($tag = db_fetch_object($result)) {
    $tag->number_of_posts = $tag->count; #sets the amount of items a certain tag has attached to it
    $tag->count = log($tag->count);
    $min = min($min, $tag->count);
    $max = max($max, $tag->count);
    $tags[$tag->tid] = $tag;
}
// Note: we need to ensure the range is slightly too large to make sure even
// the largest element is rounded down.
$range = max(.01, $max - $min) * 1.0001;

foreach ($tags as $key => $value) {
    $tags[$key]->weight = 1 + floor($steps * ($value->count - $min) / $range);
}

Then in your view or template:

foreach ($tags as $tag) {
    $output .= "<h$tag->weight>$tag->name</h$tag->weight>"
}

相关问答

更多

为什么使用.h1而不是实际的h1?(Why use .h1 instead of actual h1?)

你问: 为什么使用.h1而不是实际的h1 ? 简答: 目标是一起使用两者。 当设计中的排版大小与语义上适当的标题级别不相关时, .h*类的有用性就起作用了。 通过将问题分解为两个,我们可以干净地解决这两个问题。 第一位是元素/标签。 ' <h*> '处理语义,可访问性和SEO。 第二位是班级。 ' .h* '负责视觉语义和排版层次。 长答案: 我相信这些课程的起源来自于OOCSS项目: 面向对象的CSS OOCSS的最新版本自从我上次看到以来已经有了一些改变,但这是相关的heading.css文件...

使用h1至h6进行大小调整从阵列生成标签云的最佳方式是什么?(What's the best way to generate a tag cloud from an array using h1 through h6 for sizing?)

你也可以添加一个对数函数。 (取自tagadelic,我的Drupal模块创建标签云http://drupal.org/project/tagadelic ): db_query('SELECT COUNT(*) AS count, id, name FROM ... ORDER BY count DESC'); $steps = 6; $tags = array(); $min = 1e9; $max = -1e9; while ($tag = db_fetch_object($result...

h1 - h6标签是否应该按顺序使用,还是数字是任意的?(Should h1 - h6 tags always be used sequentially, or are the numbers arbitrary?)

HTML5规范说 4.3.10标题和章节 h1 - h6元素是标题。 切片内容元素中标题内容的第一个元素表示该部分的标题。 等级或更高等级的后续标题开始新的(隐含的)部分,较低等级的标题开始隐含的子部分是前一部分的一部分。 在这两种情况下,元素代表隐含部分的标题。 [...] 章节可能包含任何等级的标题,强烈建议作者使用适当等级的标题作为该部分的嵌套级别。 The HTML5 spec says 4.3.10 Headings and sections The h1–h6 elements are...

在标头(H1)标签中显示数组值(Display Array Value in Header (H1) Tag)

所以Dagon建议这样做: <?php error_reporting(0); include('config.php'); $table_content = ""; $employee_name = ""; $qry = "SELECT * FROM emp_data where eName='dinesh'"; $result = mysql_query($qry) or die (mysql_error()); while($row=mysql_fetch_array($result)) ...

是否有一个jQuery选择器(h1,h2,h3,h4,h5或h6)?(Is there a jQuery selector for header (h1, h2, h3, h4, h5, or h6)?)

就在这里。 您可以使用jQuery(":header")选择所有标题 以下是该文档的链接: http : //api.jquery.com/header-selector/ 请注意,由于此选择器是jQuery扩展,而不是CSS规范的一部分,因此使用此选择器的查询无法利用本机DOM querySelectorAll()方法提供的性能提升。 要在使用这些选择器时实现最佳性能,请先使用纯CSS选择器选择一些元素,然后使用.filter() 。 Yes there is. You can select a...

如何首先加载H1标签(How do I load a H1 tag first)

问题是你的背景图片和徽标图片(在h1标签中)。 尝试在图像编辑器中优化它们,并将它们保存为Web。 此外,您应该将它们保存为.jpeg ,因为它们不是透明图像,因此您可以从文件大小中节省更多。 稍后编辑:如果您想要透明徽标图像,请将其另存为jpeg for web,然后使用css opacity 。 The problem is your background image and the logo image(in the h1 tag). Try to optimize them in a im...

如何包装H1标签的内容(How to wrap content of H1 tag)

很少,文本溢出文本框。 在这种情况下,可以强制浏览器更改换行。 网页设计师墙 在这里解释: .break-word { word-wrap: break-word; } 更改渲染行为,如下所示: 另外,虽然在当前情况下可能没有帮助,但可以使用CSS 隐藏任何溢出 : style="overflow:hidden;" PS:实际上,我想知道,如果自动换行是问题的根本原因。 Quite seldom, text overflows text-boxes. In such cases, one ...

为什么CSS选择器“h1,h2,h3,h4,h5,h6 + p”不起作用,有什么替代方案?(Why doesn't CSS selector “h1,h2,h3,h4,h5,h6 + p” work, and what is an alternative?)

我认为你需要的是以下一组选择器: h1+p, h2+p, h3+p, h4+p, h5+p, h6+p 语法要求您在每个标头标记后添加“+ p”。 在当前选择器中,CSS应用于标头h1-h5和h6 + p。 这看起来可能并不优雅,但它正是您所需要的。 I think that what you need is the following group of selectors: h1+p, h2+p, h3+p, h4+p, h5+p, h6+p The syntax requires that...

操纵H1标签(Manipulation H1 Tag)

在h1标签内部取最初的html。 用br标签拆分它。 使用span标记调整已拆分html的第二部分。 使用br标记加入拆分的部分并将它们放回到h1标记中: var html = $("#title").html(); var parts = html.split("<br>"); parts[1] = "<span class='preTitle'>"+parts[1]+"</span>"; $("#title").html(parts.join("<br>")); .preTitle{ ...

无法识别附加的h1标签(Appended h1 tag not recognized)

Web爬网程序不执行JavaScript,因此不会创建<h1>标记。 如果您希望此标记对Web爬网程序可见,则需要使用服务器端语言生成它。 Web crawlers don't execute your JavaScript, so the <h1> tag isn't created. If you want this tag to be visible to web crawlers, you need to generate it with your serverside language....

相关文章

更多

Symfony2网站开发

http://blog.csdn.net/liubei5/article/details/132902 ...

Hibernate 异常之:associate a collection with two ...

Hibernate exception - Illegal attempt to associate ...

英语谚语精选(English Proverb Collection)

Lying is the first step to the gallows. 说谎是上断头台的第 ...

用好Collection 对solrj入库进行优化

今天一个朋友找我说他进行入库测试: 1个collection 2个shard,30多个字段,一个小时才 ...

Solr参数(Analysis Collection Common CoreAdmin)

一.Analysis 1.analysis.query:Holds the query to be a ...

Spark - A Fault-Tolerant Abstraction for In-Memory Cluster Computing

http://spark-project.org/ 项目首页 http://shark.cs.berk ...

Spring Data: a new perspective of data operations

Spring Data: a new perspective of data operations ...

Drupal Forums instead of phpBB or vBulletin: A casestudy

5th Jan, 10 Drupal drupal advanced forum drupa ...

Become a Master Designer: Rule Three: Contrast, Contrast, Contrast

Part Three of Seven Easy Principles to Becoming a M ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本